SIMLIB/C++
3.09
Toggle main menu visibility
Loading...
Searching...
No Matches
src
link.cc
Go to the documentation of this file.
1
/////////////////////////////////////////////////////////////////////////////
2
//! \file link.cc list item implementation
3
//
4
// Copyright (c) 1991-2016 Petr Peringer
5
//
6
// This library is licensed under GNU Library GPL. See the file COPYING.
7
//
8
9
//
10
// Link --- base class for doubly linked list items
11
//
12
13
////////////////////////////////////////////////////////////////////////////
14
// interface
15
//
16
17
#include "
simlib.h
"
18
#include "
internal.h
"
19
20
21
////////////////////////////////////////////////////////////////////////////
22
// implementation
23
//
24
25
namespace
simlib3
{
26
27
SIMLIB_IMPLEMENTATION
;
28
29
////////////////////////////////////////////////////////////////////////////
30
// Link constructors
31
//
32
Link::Link
() :
33
pred
(0),
succ
(0),
head
(0)
34
{
35
}
36
37
Link::Link
(
Link
*p,
Link
*s,
List
*h) :
38
pred
(p),
succ
(s),
head
(h)
39
{
40
}
41
42
////////////////////////////////////////////////////////////////////////////
43
// Link destructor
44
//
45
Link::~Link
() {
46
if
(
head
)
47
SIMLIB_error
(
LinkDelError
);
// remove non-linked item
48
}
49
50
////////////////////////////////////////////////////////////////////////////
51
// Into - inserts item to the list end
52
//
53
void
Link::Into
(
List
*l)
54
{
55
if
(
head
)
56
Out
();
// if in list then remove
57
l->
InsLast
(
this
);
// insert at end of list
58
}
59
60
////////////////////////////////////////////////////////////////////////////
61
// Out - takes item from list
62
//
63
void
Link::Out
()
64
{
65
if
(
head
)
66
head
->
Get
(
this
);
67
else
68
SIMLIB_error
(
LinkOutError
);
// not in list
69
}
70
71
#if 0
72
////////////////////////////////////////////////////////////////////////////
73
//
74
//
75
void
Link::Follow(
Link
*li)
// insert after li
76
{
77
if
(!li)
SIMLIB_error
(
LinkRefError
);
78
if
(
head
)
Out
();
// remove if already inserted
79
if
(li->
head
) li->
head
->
PostIns
(li);
80
else
SIMLIB_error
();
81
}
82
83
////////////////////////////////////////////////////////////////////////////
84
//
85
//
86
void
Link::Precede(
Link
*li)
// insert before li
87
{
88
if
(!li)
SIMLIB_error
(
LinkRefError
);
89
if
(
head
)
Out
();
// remove if already inserted
90
if
(li->
head
) li->
head
->
PredIns
(li);
91
else
SIMLIB_error
();
92
}
93
#endif
94
95
}
96
simlib3::Link
base class for all double-linked list items item can be at single place only (identified by where()...
Definition
simlib.h:341
simlib3::Link::head
List * head
pointer to List (if any)
Definition
simlib.h:344
simlib3::Link::~Link
virtual ~Link()
Definition
link.cc:45
simlib3::Link::succ
Link * succ
next object in List
Definition
simlib.h:343
simlib3::Link::Link
Link(Link *p, Link *s, List *h)
Definition
link.cc:37
simlib3::Link::List
friend class List
Definition
simlib.h:345
simlib3::Link::Out
virtual void Out()
remove from list
Definition
link.cc:63
simlib3::Link::Link
Link()
Definition
link.cc:32
simlib3::Link::pred
Link * pred
previous object in List
Definition
simlib.h:342
simlib3::Link::Into
virtual void Into(List *l)
insert last
Definition
link.cc:53
simlib3::List::Get
virtual Link * Get(iterator pos)
remove at position
Definition
list.cc:140
simlib3::List::PredIns
void PredIns(Link *e, iterator pos)
Definition
list.cc:106
simlib3::List::PostIns
void PostIns(Link *e, iterator pos)
Definition
list.cc:86
simlib3::List::InsLast
void InsLast(Link *e)
Definition
list.cc:71
internal.h
Internal header file for SIMLIB/C++.
simlib3
Implementation of class CalendarList interface is static - using global functions in SQS namespace.
Definition
algloop.cc:32
simlib3::SIMLIB_error
void SIMLIB_error(const enum _ErrEnum N)
print error message and abort program
Definition
error.cc:38
simlib3::SIMLIB_IMPLEMENTATION
SIMLIB_IMPLEMENTATION
Definition
algloop.cc:34
simlib3::LinkDelError
@ LinkDelError
Definition
errors.cc:26
simlib3::LinkOutError
@ LinkOutError
Definition
errors.cc:27
simlib3::LinkRefError
@ LinkRefError
Definition
errors.cc:25
simlib.h
Main SIMLIB/C++ interface.
Generated on
for SIMLIB/C++ by
1.18.0