SIMLIB/C++  3.07
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 
28 
29 ////////////////////////////////////////////////////////////////////////////
30 // Link constructors
31 //
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 //
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 
void PredIns(Link *e, iterator pos)
Definition: list.cc:106
void SIMLIB_error(const enum _ErrEnum N)
print error message and abort program
Definition: error.cc:38
virtual Link * Get(iterator pos)
remove at position
Definition: list.cc:140
void InsLast(Link *e)
Definition: list.cc:71
Implementation of class CalendarList interface is static - using global functions in SQS namespace...
Definition: algloop.cc:32
Internal header file for SIMLIB/C++.
Main SIMLIB/C++ interface.
SIMLIB_IMPLEMENTATION
Definition: algloop.cc:34
void PostIns(Link *e, iterator pos)
Definition: list.cc:86
list of Link* items, uses data from Link
Definition: simlib.h:630