[#BloombergLP-bdlc-CompactedArray]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlc.adoc[bdlc]::CompactedArray
:relfileprefix: ../../
:mrdocs:

This space&hyphen;efficient, value&hyphen;semantic array class represents a sequence of `TYPE` elements&period; The interface provides functionality similar to a `vector&lt;TYPE&gt;`, however, modifiable references to individual elements are not provided&period; This class provides accessors that return iterators that provide non&hyphen;modifiable access to its elements&period; The returned iterators, unlike those returned by a `vector&lt;TYPE&gt;`, are _not_ invalidated upon reallocation&period;

== Synopsis

Declared in `&lt;bdlc&lowbar;compactedarray&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class TYPE&gt;
class CompactedArray;
----

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlc/CompactedArray/const_iterator.adoc[`const&lowbar;iterator`] 
| Const iterator over elements of this array&period;
| xref:BloombergLP/bdlc/CompactedArray/value_type.adoc[`value&lowbar;type`] 
| Element type stored by this array&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlc/CompactedArray/2constructor-0a.adoc[`CompactedArray`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bdlc/CompactedArray/2destructor.adoc[`&#126;CompactedArray`] [.small]#[destructor]#
| Destroy this object
| xref:BloombergLP/bdlc/CompactedArray/operator_assign.adoc[`operator&equals;`] 
| Assign to this array the value of the specified `rhs` array, and return a reference providing modifiable access to this array&period;
| xref:BloombergLP/bdlc/CompactedArray/allocator.adoc[`allocator`] 
| Return the allocator used by this array to supply memory&period;
| xref:BloombergLP/bdlc/CompactedArray/append-08.adoc[`append`] 
| `append` overloads
| xref:BloombergLP/bdlc/CompactedArray/back.adoc[`back`] 
| Return a `const` reference to the element at the back of this array&period; The behavior is undefined unless `0 &lt; length()`&period; Note that this method is logically equivalent to&colon; &grave; operator &hyphen; 1) &grave;
| xref:BloombergLP/bdlc/CompactedArray/begin.adoc[`begin`] 
| Return an iterator referring to the first element in this array, or the past&hyphen;the&hyphen;end iterator if this array is empty&period; The iterator remains valid as long as this array exists&period;
| xref:BloombergLP/bdlc/CompactedArray/capacity.adoc[`capacity`] 
| Return the number of elements this array can hold, without reallocation, assuming the number of unique elements within this array does not increase&period;
| xref:BloombergLP/bdlc/CompactedArray/end.adoc[`end`] 
| Return the past&hyphen;the&hyphen;end iterator for this array&period; The iterator remains valid as long as this array exists, and its length does not decrease&period;
| xref:BloombergLP/bdlc/CompactedArray/front.adoc[`front`] 
| Return a `const` reference to the element at the front of this array&period; The behavior is undefined unless `0 &lt; length()`&period; Note that this method is logically equivalent to&colon; &grave; operator &grave;
| xref:BloombergLP/bdlc/CompactedArray/insert-03d.adoc[`insert`] 
| `insert` overloads
| xref:BloombergLP/bdlc/CompactedArray/isEmpty.adoc[`isEmpty`] 
| Return `true` if there are no elements in this array, and `false` otherwise&period;
| xref:BloombergLP/bdlc/CompactedArray/isEqual.adoc[`isEqual`] 
| Return `true` if this and the specified `other` array have the same value, and `false` otherwise&period; Two `CompactedArray` arrays have the same value if they have the same length, and all corresponding elements (those at the same indices) have the same value&period;
| xref:BloombergLP/bdlc/CompactedArray/length.adoc[`length`] 
| Return the number of elements in this array&period;
| xref:BloombergLP/bdlc/CompactedArray/operator_subs.adoc[`operator&lsqb;&rsqb;`] 
| Return a `const` reference to the element at the specified `index` in this array&period; The behavior is undefined unless `index &lt; length()`&period;
| xref:BloombergLP/bdlc/CompactedArray/pop_back.adoc[`pop&lowbar;back`] 
| Remove the last element from this array&period; The behavior is undefined unless `0 &lt; length()`&period;
| xref:BloombergLP/bdlc/CompactedArray/print.adoc[`print`] 
| Write the value of this array to the specified output `stream` in a human&hyphen;readable format, and return a reference to `stream`&period; Optionally specify an initial indentation `level`, whose absolute value is incremented recursively for nested arrays&period; If `level` is specified, optionally specify `spacesPerLevel`, whose absolute value indicates the number of spaces per indentation level for this and all of its nested arrays&period; If `level` is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by `level`)&period; If `stream` is not valid on entry, this operation has no effect&period; Note that the format is not fully specified, and can change without notice&period;
| xref:BloombergLP/bdlc/CompactedArray/push_back.adoc[`push&lowbar;back`] 
| Append to this array an element having the specified `value`&period;
| xref:BloombergLP/bdlc/CompactedArray/remove-00.adoc[`remove`] 
| `remove` overloads
| xref:BloombergLP/bdlc/CompactedArray/removeAll.adoc[`removeAll`] 
| Remove all the elements from this array&period;
| xref:BloombergLP/bdlc/CompactedArray/replace-0c.adoc[`replace`] 
| `replace` overloads
| xref:BloombergLP/bdlc/CompactedArray/reserveCapacity-08.adoc[`reserveCapacity`] 
| `reserveCapacity` overloads
| xref:BloombergLP/bdlc/CompactedArray/resize.adoc[`resize`] 
| Set the length of this array to the specified `numElements`&period; If `numElements &gt; length()`, the added elements are initialized to `TYPE()`&period;
| xref:BloombergLP/bdlc/CompactedArray/swap.adoc[`swap`] 
| Efficiently exchange the value of this array with the value of the specified `other` array&period; This method provides the no&hyphen;throw exception&hyphen;safety guarantee&period; The behavior is undefined unless this array was created with the same allocator as `other`&period;
| xref:BloombergLP/bdlc/CompactedArray/uniqueElement.adoc[`uniqueElement`] 
| Return a `const` reference to the element at the specified `index` within the sorted sequence of unique element values in this object&period; The behavior is undefined unless `index &lt; uniqueLength()`&period; Note that `uniqueElement(index)` and `operator` can return different objects&period;
| xref:BloombergLP/bdlc/CompactedArray/uniqueLength.adoc[`uniqueLength`] 
| Return the number of unique elements in this array&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlc/operator_not_eq-0b4.adoc[`operator!&equals;`]
| Return `true` if the specified `lhs` and `rhs` arrays do not have the same value, and `false` otherwise&period; Two `CompactedArray` arrays do not have the same value if they do not have the same length, or if any corresponding elements (those at the same indices) do not have the same value&period;
| xref:BloombergLP/bdlc/operator_eq-085.adoc[`operator&equals;&equals;`]
| Return `true` if the specified `lhs` and `rhs` arrays have the same value, and `false` otherwise&period; Two `CompactedArray` arrays have the same value if they have the same length, and all corresponding elements (those at the same indices) have the same value&period;
| xref:BloombergLP/bdlc/swap-03.adoc[`swap`]
| Exchange the values of the specified `a` and `b` objects&period; This function provides the no&hyphen;throw exception&hyphen;safety guarantee if the two objects were created with the same allocator and the basic guarantee otherwise&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
