94 #ifndef Foam_CircularBuffer_H 95 #define Foam_CircularBuffer_H 113 Ostream& operator<<(Ostream& os, const CircularBuffer<T>& rhs);
138 inline label toGlobal(
const label i)
const;
141 inline label size_one()
const noexcept;
144 inline label size_two()
const noexcept;
149 void doReserve(
const bool nocopy,
const label len);
152 template<
class OtherListType>
153 inline void copyList(
const OtherListType& rhs);
258 const
T&
back() const;
266 inline
void reserve(const label len);
289 label
find(const
T& val, label
pos = 0) const;
295 inline
bool contains(const
T& val, label
pos = 0) const;
369 template<
class AnyAddr>
432 return (*container_)[iter_];
450 return iter_ == rhs.iter_;
455 return iter_ != rhs.iter_;
463 inline const_iterator
cbegin()
const 465 return const_iterator(
this, 0);
469 inline const_iterator
cend()
const 471 return const_iterator(
this, this->
size());
475 inline const_iterator
begin()
const {
return cbegin(); }
478 inline const_iterator
end()
const {
return cend(); }
484 bool found(
const T& val, label
pos = 0)
const 527 Istream&
operator>>(Istream& is, CircularBuffer<T>& rhs)
529 return rhs.readList(is);
536 Ostream& operator<<(Ostream& os, const CircularBuffer<T>& rhs)
538 return rhs.writeList(
os);
void swap(CircularBuffer< T > &other)
Swap content, independent of sizing parameter.
Ostream & writeList(Ostream &os, const label shortLen=0) const
Write buffer contents with line-breaks in ASCII when length exceeds shortLen.
const_iterator(const const_iterator &)=default
label size_type
The type to represent the size of a buffer.
std::forward_iterator_tag iterator_category
void pop_front(label n=1)
Shrink by moving the front of the buffer 1 or more times.
constexpr CircularBuffer() noexcept
Default construct, empty buffer without allocation.
label difference_type
The difference between iterator objects.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
labelRange range_two() const noexcept
The addressing range covered by array_two()
A range or interval of labels defined by a start and a size.
void clear() noexcept
Clear the addressed buffer, does not change allocation.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
void push_front(const T &val)
Copy prepend an element to the front of the buffer.
bool found(const T &val, label pos=0) const
Same as contains()
reference operator*() const
const T & const_reference
The type used for reading from constant value_type objects.
const_iterator end() const
Return a const_iterator at end of buffer.
label size() const noexcept
The current number of buffer items.
T & back()
Access the last element (back). Requires !empty().
Base for lists with indirect addressing, templated on the list contents type and the addressing type...
const_iterator cend() const
Return a const_iterator at end of buffer.
const_iterator begin() const
Return a const_iterator at begin of buffer.
bool contains(const T &val, label pos=0) const
Is the value contained in the list?
bool empty() const noexcept
Empty or exhausted buffer.
const_iterator cbegin() const
Return a const_iterator at begin of buffer.
void clearStorage()
Clear the buffer and delete storage.
T & operator[](const label i)
Non-const access to an element in the list.
dimensionedScalar pos(const dimensionedScalar &ds)
Istream & readList(Istream &is)
Read buffer contents from Istream.
List< T > list() const
Return a copy of the buffer flattened into a single List. Use sparingly!
A List obtained as a section of another List.
A simple list of objects of type <T> that is intended to be used as a circular buffer (eg...
Istream & operator>>(Istream &, directionInfo &)
void pop_back(label n=1)
Shrink by moving the end of the buffer 1 or more times.
const_iterator & operator=(const const_iterator &)=default
labelRange range_one() const noexcept
The addressing range covered by array_one()
friend Ostream & operator(Ostream &os, const CircularBuffer< T > &list)
Write to Ostream.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
An Ostream is an abstract base class for all output systems (streams, files, token lists...
OBJstream os(runTime.globalPath()/outputName)
void append(const T &val)
Copy append an element to the end of the buffer.
T & front()
Access the first element (front). Requires !empty().
static constexpr label min_size() noexcept
Lower capacity limit.
T & reference
The type used for storing into value_type objects.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
label space() const noexcept
The nominal space available to fill. Subtract 1 for the number to append before re-balancing is neede...
SubList< T > array_one()
The contents of the first internal array.
void reserve_nocopy(const label len)
Reserve allocation space for at least this size, allocating new space if required without retaining o...
const_iterator & operator++()
void operator=(const CircularBuffer< T > &list)
Copy construct.
T & last()
Access the last element (back). Requires !empty().
A simple forward const iterator for a circular buffer.
T & first()
Access the first element (front). Requires !empty().
T * pointer
The pointer type for non-const access to value_type items.
bool operator!=(const const_iterator &rhs) const
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
void push_back(const T &val)
Copy append an element to the end of the buffer.
const T * const_pointer
The pointer type for const access to value_type items.
bool operator==(const const_iterator &rhs) const
Ostream & info(Ostream &os) const
Print information.
T value_type
The value type the list contains.
label capacity() const noexcept
Size of the underlying storage.
SubList< T > array_two()
The contents of the first internal array.
void reverse()
Reverse the buffer order, swapping elements.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
label appendUniq(const T &val)
Append an element if not already in the buffer.
label push_uniq(const T &val)
Append an element if not already in the buffer.
void reserve(const label len)
Reserve allocation space for at least this size, allocating new space if required and retaining old c...