Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

ring.h
Go to the documentation of this file.
1 
30 #pragma once
31 
33 
34 
35 namespace abacus {
36 
37 template <class Type>
38 class AbaRing;
39 
40 template <class Type>
41 std::ostream &operator<< (std::ostream &out, const AbaRing<Type> &ring);
42 
43 
45 
51 template <class Type> class AbaRing : public AbacusRoot {
52 public:
53 
55 
58  explicit AbaRing(int size);
59 
61  virtual ~AbaRing() { }
62 
64 
73  friend std::ostream &operator<< <> (std::ostream &out, const AbaRing<Type> &ring);
74 
76 
81  Type& operator[](int i);
82 
84  const Type& operator[](int i) const;
85 
87 
93  void insert(Type elem);
94 
96  void clear();
97 
99  int size() const;
100 
102  int number() const;
103 
105 
108  Type oldest() const;
109 
111 
114  int oldestIndex() const;
115 
117 
120  Type newest() const;
121 
123 
126  int newestIndex() const;
127 
129 
139  int previous(int i, Type &p) const;
140 
142  bool empty() const;
143 
145  bool filled() const;
146 
148 
153  void realloc(int newSize);
154 
155 private:
156 
159 
161  int head_;
162 
164  bool filled_;
165 };
166 
167 }
168 
169 #include <ogdf/lib/abacus/ring.inc>
bool filled_
This member becomes true if ring is completely filled up.
Definition: ring.h:164
The parameterized class Array implements dynamic arrays of type E.
Definition: Array.h:200
Base class of all other classes of ABACUS.
Definition: abacusroot.h:68
Array< Type > ring_
An array storing the elements of the ring.
Definition: ring.h:158
Type oldest() const
Returns the oldest element in the ring.
AbaRing(int size)
The constructor.
void realloc(int newSize)
Changes the length of the ring.
Type & operator[](int i)
Returns the i-th element of the ring.
bool empty() const
Returns true if no element is contained in the ring, false otherwise.
Bounded circular lists.
Definition: ring.h:38
int newestIndex() const
Returns the index of the newest element in the ring.
void clear()
Empties the ring.
int size() const
Returns the size of the ring.
int previous(int i, Type &p) const
Can be used to access any element between the oldest and newest inserted element. ...
void insert(Type elem)
Inserts a new element into the ring.
int head_
The position in the array ring_ where the next element will be inserted.
Definition: ring.h:161
virtual ~AbaRing()
The destructor.
Definition: ring.h:61
Type newest() const
Returns the newest element in the ring.
bool filled() const
Returns true If the ring is completely filled up, false otherwise.
int oldestIndex() const
Returns the index of the oldest element in the ring.
int number() const
Returns the current number of elements in the ring.