23const int nper =
sizeof (
unsigned int) * CHAR_BIT;
95 v |= ((
m_vec[ndx+1] & mask(bits)) << (nper - off));
120 m_vec[ndx+1] = (
m_vec[ndx+1] & ~mask2) | ((v >> (nper - off)) & mask2);
203 return m_vec.get_allocator();
221 return m_vec.max_size();
247 for (
size_t i =
m_size; i <
sz; i++)
261 m_vec[ndx] &= mask (off);
334 return proxy (*
this, n);
364 return proxy (*
this, n);
403 return proxy (*
this, 0);
428 if (nb !=
m_vec.size())
441 if (nb !=
m_vec.size())
An array of unsigned values of some bit size, packed tightly.
proxy class for representing an lvalue to an element of PackedArray.
int m_bitsize
The current bitsize of the container.
size_type size() const
Returns the number of elements in the collection.
void set_bitsize(int bitsize)
Change the bitsize of the container.
allocator_type get_allocator() const
Returns the allocator of the underlying vector.
size_t tondx(size_type n) const
Find the index in the base vector where entry starts.
void clear()
Erase all the elements in the collection.
size_type m_size
The current number of entries in the container.
value_type front() const
Access the first element in the collection as an rvalue.
value_type operator[](size_type n) const
Access an element, as an rvalue.
value_type m_mask
Mask with m_bitsize bits set.
size_type capacity() const
Returns the total number of elements that the collection can hold before needing to allocate more mem...
basetype m_vec
Underlying vector holding the data.
void range_check(size_type n) const
Check that n is in range and throw out_of_range if not.
value_type doget(size_type ndx, int off) const
Return the entry at base index ndx/offset off.
PackedArray(int bitsize=8, const allocator_type &allocator=allocator_type())
Constructor.
void doset(size_type ndx, int off, value_type v)
Set the entry at base index ndx/offset off to v.
int bitsize() const
Return the bitsize of the container.
value_type at(size_type n) const
Access an element, as an rvalue.
size_type max_size() const
Returns the size() of the largest possible collection.
void resize(size_type sz, value_type c=0)
Resizes the collection to the specified number of elements.
int tooff(size_type n) const
Find the bit offset of entry within its entry in the base vector.
value_type get(size_type n) const
Return the entry at index n.
void assign(size_type n, value_type u)
Set the container to multiple copies of the same value.
bool empty() const
Returns true if the collection is empty.
void push_back(value_type x)
Add an element to the end of the collection.
value_type back() const
Access the last element in the collection as an rvalue.
void swap(PackedArray &other)
Swap this collection with another.
void pop_back()
Remove the last element from the collection.
size_t nbase(size_type n) const
Calculate the number of entries in the base vector needed to hold entries with the current bitsize.
basetype::allocator_type allocator_type
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
void set(size_type n, value_type val)
Set the entry at index n.
void throw_out_of_range(const std::string &what, size_t index, size_t size, const void *obj)
Throw an out_of_range exception.
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)
Helpers for throwing out_of_range exceptions.