31#pragma GCC visibility push(default)
45std::ostream &
operator<<(std::ostream &out,
const AbaRing<Type> &rhs)
48 const int s = rhs.size();
50 for(
int i = rhs.head_; i < s; i++)
51 out << rhs.ring_[i] <<
" ";
54 for (
int i = 0; i < rhs.head_; i++)
55 out << rhs.ring_[i] <<
" ";
64inline Type& AbaRing<Type>::operator[](
int i)
71inline const Type& AbaRing<Type>::operator[](
int i)
const
78void AbaRing<Type>::insert(Type elem)
82 if (++head_ ==
size()) {
83 if (!filled_) filled_ =
true;
90inline void AbaRing<Type>::clear()
98inline int AbaRing<Type>::size()
const
105inline int AbaRing<Type>::number()
const
115inline Type AbaRing<Type>::oldest()
const
117 if(filled_)
return ring_[head_];
118 else return ring_[0];
123inline int AbaRing<Type>::oldestIndex()
const
125 if(filled_)
return head_;
131inline Type AbaRing<Type>::newest()
const
133 if (head_)
return ring_[head_ - 1];
134 else return ring_[
size() - 1];
139inline int AbaRing<Type>::newestIndex()
const
141 if (head_)
return head_ - 1;
142 else return size() - 1;
147int AbaRing<Type>::previous(
int i, Type &p)
const
149 int j = head_ - 1 - i;
156 p = ring_[
size() + j];
164inline bool AbaRing<Type>::empty()
const
166 return !(head_ || filled_);
171inline bool AbaRing<Type>::filled()
const
178void AbaRing<Type>::realloc(
int newSize)
180 Array<Type> tmp = ring_;
181 int oldSize =
size();
185 ring_.realloc(newSize);
187 if(newSize > oldSize) {
195 for(i = oldHead; i < oldSize; i++) ring_[head_++] = tmp[i];
196 for(i = 0; i < oldHead; i++) ring_[head_++] = tmp[i];
207 for (head_ =
size() - 1, i = oldHead - 1; head_ >= 0; head_--, i--) {
208 if (i < 0) i = oldSize - 1;
209 ring_[head_] = tmp[i];
213 else if (oldHead >
size()) {
214 for (head_ =
size() - 1, i = oldHead - 1; head_ >= 0; --head_, --i)
215 ring_[head_] = tmp[i];
223#pragma GCC visibility pop
AbaRing(int size)
The constructor.
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.