105 #include <type_traits>
117 template<
unsigned nBits>
class PackedList;
119 template<
unsigned nBits>
120 void writeEntry(Ostream& os,
const PackedList<nBits>&);
122 template<
unsigned nBits>
125 template<
unsigned nBits>
149 template<
unsigned nBits=1>
153 private List<unsigned int>
183 "nBits must be positive (non-zero) and fit within the storage"
198 inline static unsigned int max_bits();
205 inline static unsigned int packing();
259 inline bool empty()
const;
263 inline unsigned int get(
const label)
const;
268 inline bool set(
const label,
const unsigned int val = ~0u);
286 inline std::streamsize
byteSize()
const;
291 unsigned int count()
const;
328 inline void resize(
const label,
const unsigned int& val = 0u);
331 inline void setSize(
const label,
const unsigned int& val = 0u);
376 const bool indexedOutput=
false
386 inline unsigned int remove();
398 inline void operator=(
const unsigned int val);
437 inline unsigned int get()
const;
440 inline bool set(
unsigned int);
481 inline void operator=(
const unsigned int val);
485 inline operator unsigned int ()
const;
623 friend Istream&
operator>> <nBits>
629 friend Ostream& operator<< <nBits>
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
The const_iterator for PackedList.
void operator=(const iteratorBase &)
Assign from iteratorBase or derived.
bool operator==(const iteratorBase &) const
Compare positions (not values)
const_iterator & operator--()
unsigned int operator()() const
Return referenced value directly.
const_iterator & operator++()
bool operator!=(const iteratorBase &) const
const_iterator()
Construct null.
unsigned int operator*() const
Return referenced value directly.
The iterator base for PackedList.
void operator=(const iteratorBase &)
Assign value, not position.
bool operator==(const iteratorBase &) const
Compare values (not positions)
label key() const
Return the element index corresponding to the iterator.
Ostream & printInfo(Ostream &) const
Print information and values.
bool operator!=(const iteratorBase &) const
bool set(unsigned int)
Set value, returning true if changed, no range-checking.
iteratorBase()
Construct null.
label index_
Element index.
unsigned int get() const
Get value as unsigned, no range-checking.
bool writeIfSet(Ostream &) const
Write index/value for a non-zero entry.
PackedList * list_
Pointer to original list.
The iterator class used for PackedList.
bool operator==(const iteratorBase &) const
Compare positions (not values)
unsigned int operator()() const
Return value.
iterator()
Construct null.
bool operator!=(const iteratorBase &) const
unsigned int operator*() const
Return value.
A dynamically allocatable list of packed unsigned integers.
static unsigned int max_value()
The max. value for an entry, which simultaneously the bit-mask.
autoPtr< PackedList< nBits > > clone() const
Clone.
void flip()
Invert the bits in the addressable region.
void shrink()
Shrink the allocated space to what is actually used.
List< unsigned int > & storage()
Return the underlying packed storage.
bool set(const label, const unsigned int val=~0u)
Set value at index I. Return true if value changed.
static unsigned int maskLower(unsigned offset)
Masking for all bits below the offset.
Istream & read(Istream &)
Clear list and read from stream.
void resize(const label, const unsigned int &val=0u)
Reset addressable list size, does not shrink the allocated size.
void setSize(const label, const unsigned int &val=0u)
Alias for resize()
void setCapacity(const label)
Alter the size of the underlying storage.
labelList values() const
Return the values as a list of labels.
label size() const
Number of entries.
void transfer(PackedList< nBits > &)
Transfer the contents of the argument list into this list.
label capacity() const
The number of elements that can be stored before reallocating.
bool trim()
Trim any trailing zero elements.
label packedLength() const
The list length when packed.
void setPair(Istream &)
Read an index/value pair and set accordingly.
iterator end()
Iterator set to beyond the end of the PackedList.
bool empty() const
Return true if the list is empty (ie, size() is zero).
static unsigned int packing()
The number of entries per packed storage element.
List< StorageType > StorageList
const_iterator cend() const
const_iterator set to beyond the end of the PackedList
iterator begin()
Iterator set to the beginning of the PackedList.
void reserve(const label)
Reserve allocation space for at least this size.
unsigned int get(const label) const
Get value at index I.
void clearStorage()
Clear the list and delete storage.
PackedList()
Null constructor.
static unsigned int max_bits()
The max. number of bits that can be templated.
const_iterator cbegin() const
const_iterator set to the beginning of the PackedList
bool unset(const label)
Unset the entry at index I. Return true if value changed.
void operator=(const unsigned int val)
Assignment of all entries to the given value. Takes linear time.
std::streamsize byteSize() const
Return the binary size in number of characters.
static unsigned int readValue(Istream &)
Read a list entry (allows for specialisation)
PackedList< nBits > & append(const unsigned int val)
Append a value at the end of the list.
void clear()
Clear the list, i.e. set addressable size to zero.
unsigned int operator[](const label) const
Get value at index I.
unsigned int count() const
Count number of bits set, O(log(n))
void reset()
Clear all bits.
Ostream & printInfo(Ostream &, const bool fullOutput=false) const
Print information and bit patterns (with printBits)
Ostream & printBits(Ostream &, const bool fullOutput=false) const
Print bit patterns, optionally output unused elements.
unsigned int remove()
Remove and return the last element.
Ostream & write(Ostream &, const bool indexedOutput=false) const
Write, optionally with indexedOutput.
A List with indirect addressing.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Istream & operator>>(Istream &, pistonPointEdgeData &)
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
void offset(label &lst, const label o)
Template-invariant bits for PackedList.
PackedListCore()
Construct null.
ClassName("PackedList")
Define template name and debug.