Space‐efficient value‐semantic array of TYPE elements.

Synopsis

Declared in <bdlc_compactedarray.h>

template<class TYPE>
class CompactedArray;

Description

This space‐efficient, value‐semantic array class represents a sequence of TYPE elements. The interface provides functionality similar to a vector<TYPE>, however, modifiable references to individual elements are not provided. This class provides accessors that return iterators that provide non‐modifiable access to its elements. The returned iterators, unlike those returned by a vector<TYPE>, are not invalidated upon reallocation.

Type Aliases

Name

Description

const_iterator

Const iterator over elements of this array.

value_type

Element type stored by this array.

Member Functions

Name

Description

CompactedArray [constructor]

Constructors

~CompactedArray [destructor]

Destroy this object

operator=

Assign to this array the value of the specified rhs array, and return a reference providing modifiable access to this array.

allocator

Return the allocator used by this array to supply memory.

append

append overloads

back

Return a const reference to the element at the back of this array.

begin

Return an iterator referring to the first element in this array.

capacity

Return the number of elements this array can hold, without reallocation, assuming the number of unique elements within this array does not increase.

end

Return the past‐the‐end iterator for this array. The iterator remains valid as long as this array exists, and its length does not decrease.

front

Return a const reference to the element at the front of this array.

insert

insert overloads

isEmpty

Return true if there are no elements in this array, and false otherwise.

isEqual

Return true if this and the specified other array have the same value.

length

Return the number of elements in this array.

operator[]

Return a const reference to the element at index.

pop_back

Remove the last element from this array. The behavior is undefined unless 0 < length().

print

Write the value of this array to the specified output stream.

push_back

Append to this array an element having the specified value.

remove

remove overloads

removeAll

Remove all the elements from this array.

replace

replace overloads

reserveCapacity

Make the capacity of this array at least the specified numElements.

resize

Set the length of this array to the specified numElements.

swap

Efficiently exchange the value of this array with that of other.

uniqueElement

Return a const reference to the unique element at the specified index.

uniqueLength

Return the number of unique elements in this array.

Non-Member Functions

Name

Description

operator!=

Return true if the specified lhs and rhs arrays do not have the same value, and false otherwise.

operator==

Return true if the specified lhs and rhs arrays have the same value, and false otherwise.

swap

Exchange the values of the specified a and b objects.

Created with MrDocs