blocxx
|
Array<> wraps std::vector<> in COWReference<> adding ref counting and copy on write capability. More...
#include <Array.hpp>
Public Types | |
typedef V::value_type | value_type |
typedef V::pointer | pointer |
typedef V::const_pointer | const_pointer |
typedef V::iterator | iterator |
typedef V::const_iterator | const_iterator |
typedef V::reference | reference |
typedef V::const_reference | const_reference |
typedef V::size_type | size_type |
typedef V::difference_type | difference_type |
typedef V::reverse_iterator | reverse_iterator |
typedef V::const_reverse_iterator | const_reverse_iterator |
Public Member Functions | |
Array () | |
Default Constructor. | |
~Array () | |
Destructor. | |
Array (V *toWrap) | |
Constructor. | |
Array (size_type n, const T &value) | |
Construct an Array that consist of a specified number of elements that are copies of a given object. | |
Array (int n, const T &value) | |
Construct an Array that consist of a specified number of elements that are copies of a given object. | |
Array (long n, const T &value) | |
Construct an Array that consist of a specified number of elements that are copies of a given object. | |
Array (size_type n) | |
Construct an Array that consist of a specified number of elements that have be constructed using the default constructor of class T. | |
template<class InputIterator > | |
Array (InputIterator first, InputIterator last) | |
Construct an Array from a range specified with InputIterators. | |
iterator | begin () |
const_iterator | begin () const |
iterator | end () |
const_iterator | end () const |
reverse_iterator | rbegin () |
const_reverse_iterator | rbegin () const |
reverse_iterator | rend () |
const_reverse_iterator | rend () const |
size_type | size () const |
size_type | max_size () const |
size_type | capacity () const |
bool | empty () const |
reference | operator[] (size_type n) |
Retrieve A read/write reference to an object in the Array at a given index. | |
const_reference | operator[] (size_type n) const |
Retrieve A read only reference to an object in the Array at a given index. | |
Array< T > & | operator+= (const T &x) |
Append an object to the end of the Array. | |
void | reserve (size_type n) |
Ensure the capacity is at least the size of a given value. | |
reference | front () |
const_reference | front () const |
reference | back () |
const_reference | back () const |
void | push_back (const T &x) |
Append an element to the end of the Array. | |
void | append (const T &x) |
Append an element to the end of the Array. | |
void | swap (Array< T > &x) |
Swap the elements of this Array with the elements of another. | |
iterator | insert (iterator position, const T &x) |
Insert an element in the Array before an element specified by an iterator. | |
void | insert (size_type position, const T &x) |
Insert an element in the Array before an element specified by an index. | |
void | remove (size_type index) |
Remove an element from the Array at a given index. | |
void | remove (size_type begin, size_type end) |
Remove an element specified by a range. | |
template<class InputIterator > | |
void | insert (iterator position, InputIterator first, InputIterator last) |
Insert a range of elements before a given position in the Array. | |
void | appendArray (const Array< T > &x) |
Append the elements of another Array to the end of this Array. | |
void | pop_back () |
Remove the last element of the Array. | |
iterator | erase (iterator position) |
Remove an element of the Array specified with an iterator. | |
iterator | erase (iterator first, iterator last) |
Remove elements of the Array specified by a beginning and ending iterator. | |
void | resize (size_type new_size, const T &x) |
Ensure the Array is a given size. | |
void | resize (size_type new_size) |
Ensure the Array is a given size. | |
void | clear () |
Remove all items from the Array. | |
const_iterator | find (const T &x, const_iterator first, const_iterator last) const |
Find element x in the array range specified by the first and last iterators. | |
const_iterator | find (const T &x) const |
Find element x in the array. | |
iterator | find (const T &x, iterator first, iterator last) |
Find element x in the array range specified by the first and last iterators. | |
iterator | find (const T &x) |
Find element x in the array. | |
bool | contains (const T &x, const_iterator first, const_iterator last) const |
Determine if element x is contained in the array range specified by the first and last iterators. | |
bool | contains (const T &x) const |
Determine if element x is contained in the array. | |
Private Types | |
typedef std::vector< T, std::allocator< T > > | V |
Private Attributes | |
COWReference< V > | m_impl |
Friends | |
bool | operator== (const Array< T > &x, const Array< T > &y) |
Determine equality of two Arrays. | |
bool | operator< (const Array< T > &x, const Array< T > &y) |
Determine if one Array is less than another. |
Array<> wraps std::vector<> in COWReference<> adding ref counting and copy on write capability.
It also adds valid range checks to operator[] if BLOCXX_CHECK_ARRAY_INDEXING is defined.
Invariants: See std::vector<> Thread safety: read Copy semantics: Copy On Write Exception safety: same as std::vector<T>
typedef V::const_iterator BLOCXX_NAMESPACE::Array< T >::const_iterator |
typedef V::const_pointer BLOCXX_NAMESPACE::Array< T >::const_pointer |
typedef V::const_reference BLOCXX_NAMESPACE::Array< T >::const_reference |
Reimplemented in BLOCXX_NAMESPACE::Stack< T >.
typedef V::const_reverse_iterator BLOCXX_NAMESPACE::Array< T >::const_reverse_iterator |
typedef V::difference_type BLOCXX_NAMESPACE::Array< T >::difference_type |
typedef V::iterator BLOCXX_NAMESPACE::Array< T >::iterator |
typedef V::pointer BLOCXX_NAMESPACE::Array< T >::pointer |
typedef V::reference BLOCXX_NAMESPACE::Array< T >::reference |
Reimplemented in BLOCXX_NAMESPACE::Stack< T >.
typedef V::reverse_iterator BLOCXX_NAMESPACE::Array< T >::reverse_iterator |
typedef V::size_type BLOCXX_NAMESPACE::Array< T >::size_type |
Reimplemented in BLOCXX_NAMESPACE::Stack< T >.
typedef std::vector<T, std::allocator<T> > BLOCXX_NAMESPACE::Array< T >::V [private] |
typedef V::value_type BLOCXX_NAMESPACE::Array< T >::value_type |
BLOCXX_NAMESPACE::Array< T >::Array | ( | ) | [inline] |
Default Constructor.
Definition at line 55 of file ArrayImpl.hpp.
BLOCXX_NAMESPACE::Array< T >::~Array | ( | ) | [inline] |
Destructor.
Definition at line 61 of file ArrayImpl.hpp.
BLOCXX_NAMESPACE::Array< T >::Array | ( | V * | toWrap | ) | [inline, explicit] |
Constructor.
toWrap | The std::vector to wrap with this Array object. |
Definition at line 66 of file ArrayImpl.hpp.
BLOCXX_NAMESPACE::Array< T >::Array | ( | size_type | n, |
const T & | value | ||
) | [inline] |
Construct an Array that consist of a specified number of elements that are copies of a given object.
n | Number of elements the Array will contain. |
value | The value every element of the array will be initialized to. |
Definition at line 72 of file ArrayImpl.hpp.
BLOCXX_NAMESPACE::Array< T >::Array | ( | int | n, |
const T & | value | ||
) | [inline] |
Construct an Array that consist of a specified number of elements that are copies of a given object.
n | Number of elements the Array will contain. |
value | The value every element of the array will be initialized to. |
Definition at line 78 of file ArrayImpl.hpp.
BLOCXX_NAMESPACE::Array< T >::Array | ( | long | n, |
const T & | value | ||
) | [inline] |
Construct an Array that consist of a specified number of elements that are copies of a given object.
n | Number of elements the Array will contain. |
value | The value every element of the array will be initialized to. |
Definition at line 84 of file ArrayImpl.hpp.
BLOCXX_NAMESPACE::Array< T >::Array | ( | size_type | n | ) | [inline, explicit] |
Construct an Array that consist of a specified number of elements that have be constructed using the default constructor of class T.
n | Number of elements the Array will contain. |
Definition at line 90 of file ArrayImpl.hpp.
BLOCXX_NAMESPACE::Array< T >::Array | ( | InputIterator | first, |
InputIterator | last | ||
) | [inline] |
Construct an Array from a range specified with InputIterators.
first | The iterator for the beginning of the range. |
last | The iterator for the end of the range. |
Definition at line 97 of file ArrayImpl.hpp.
void BLOCXX_NAMESPACE::Array< T >::append | ( | const T & | x | ) | [inline] |
Append an element to the end of the Array.
This is identical to push_back.
x | The element to append to the end of the Array. |
Definition at line 258 of file ArrayImpl.hpp.
Referenced by BLOCXX_NAMESPACE::MultiAppender::addLogAppender(), BLOCXX_NAMESPACE::DelayedFormat::append(), BLOCXX_NAMESPACE::FileSystem::getDirectoryContents(), and BLOCXX_NAMESPACE::String::tokenize().
void BLOCXX_NAMESPACE::Array< T >::appendArray | ( | const Array< T > & | x | ) | [inline] |
Append the elements of another Array to the end of this Array.
x | The Array the elements will be copied from. |
Definition at line 315 of file ArrayImpl.hpp.
References BLOCXX_NAMESPACE::Array< T >::begin(), and BLOCXX_NAMESPACE::Array< T >::end().
Array< T >::reference BLOCXX_NAMESPACE::Array< T >::back | ( | ) | [inline] |
Definition at line 237 of file ArrayImpl.hpp.
References m_impl.
Referenced by BLOCXX_NAMESPACE::Stack< T >::top().
Array< T >::const_reference BLOCXX_NAMESPACE::Array< T >::back | ( | ) | const [inline] |
Definition at line 244 of file ArrayImpl.hpp.
References m_impl.
Array< T >::const_iterator BLOCXX_NAMESPACE::Array< T >::begin | ( | ) | const [inline] |
Definition at line 111 of file ArrayImpl.hpp.
References m_impl.
Array< T >::iterator BLOCXX_NAMESPACE::Array< T >::begin | ( | ) | [inline] |
Definition at line 104 of file ArrayImpl.hpp.
References m_impl.
Referenced by BLOCXX_NAMESPACE::Array< T >::appendArray(), BLOCXX_NAMESPACE::Cstr::CstrArr< Array< S > >::CstrArr(), and BLOCXX_NAMESPACE::DateTime::DateTime().
Array< T >::size_type BLOCXX_NAMESPACE::Array< T >::capacity | ( | ) | const [inline] |
Definition at line 174 of file ArrayImpl.hpp.
References m_impl.
void BLOCXX_NAMESPACE::Array< T >::clear | ( | ) | [inline] |
Remove all items from the Array.
The size() of the Array should be zero after calling this method.
Definition at line 357 of file ArrayImpl.hpp.
References m_impl.
Referenced by BLOCXX_NAMESPACE::FileSystem::getDirectoryContents().
bool BLOCXX_NAMESPACE::Array< T >::contains | ( | const T & | x, |
const_iterator | first, | ||
const_iterator | last | ||
) | const [inline] |
Determine if element x is contained in the array range specified by the first and last iterators.
x | The element to seach for. |
first | The first position iterator; begin of the range. |
last | The last position iterator; end of the range. |
Definition at line 406 of file ArrayImpl.hpp.
bool BLOCXX_NAMESPACE::Array< T >::contains | ( | const T & | x | ) | const [inline] |
Determine if element x is contained in the array.
x | The element to seach for. |
Definition at line 413 of file ArrayImpl.hpp.
bool BLOCXX_NAMESPACE::Array< T >::empty | ( | ) | const [inline] |
Reimplemented in BLOCXX_NAMESPACE::Stack< T >.
Definition at line 181 of file ArrayImpl.hpp.
References m_impl.
Referenced by BLOCXX_NAMESPACE::SelectEngine::go(), and BLOCXX_NAMESPACE::UTF8Utils::UCS2ToString().
Array< T >::const_iterator BLOCXX_NAMESPACE::Array< T >::end | ( | ) | const [inline] |
Definition at line 125 of file ArrayImpl.hpp.
References m_impl.
Array< T >::iterator BLOCXX_NAMESPACE::Array< T >::end | ( | ) | [inline] |
Definition at line 118 of file ArrayImpl.hpp.
References m_impl.
Referenced by BLOCXX_NAMESPACE::Array< T >::appendArray(), BLOCXX_NAMESPACE::Cstr::CstrArr< Array< S > >::CstrArr(), and BLOCXX_NAMESPACE::DateTime::DateTime().
Array< T >::iterator BLOCXX_NAMESPACE::Array< T >::erase | ( | iterator | first, |
iterator | last | ||
) | [inline] |
Remove elements of the Array specified by a beginning and ending iterator.
first | An iterator that specifies the first element to remove. |
last | An iterator that specifies the last element to remove. |
Definition at line 336 of file ArrayImpl.hpp.
References m_impl.
Array< T >::iterator BLOCXX_NAMESPACE::Array< T >::erase | ( | iterator | position | ) | [inline] |
Remove an element of the Array specified with an iterator.
position | An iterator that points to the element to be removed. |
Definition at line 329 of file ArrayImpl.hpp.
References m_impl.
Array< T >::iterator BLOCXX_NAMESPACE::Array< T >::find | ( | const T & | x | ) | [inline] |
Find element x in the array.
x | The element to seach for. |
Definition at line 399 of file ArrayImpl.hpp.
Array< T >::const_iterator BLOCXX_NAMESPACE::Array< T >::find | ( | const T & | x, |
const_iterator | first, | ||
const_iterator | last | ||
) | const [inline] |
Find element x in the array range specified by the first and last iterators.
x | The element to seach for. |
first | The first position iterator; begin of the range. |
last | The last position iterator; end of the range. |
Definition at line 364 of file ArrayImpl.hpp.
Referenced by BLOCXX_NAMESPACE::Stack< T >::search().
Array< T >::iterator BLOCXX_NAMESPACE::Array< T >::find | ( | const T & | x, |
iterator | first, | ||
iterator | last | ||
) | [inline] |
Find element x in the array range specified by the first and last iterators.
x | The element to seach for. |
first | The first position iterator; begin of the range. |
last | The last position iterator; end of the range. |
Definition at line 385 of file ArrayImpl.hpp.
Array< T >::const_iterator BLOCXX_NAMESPACE::Array< T >::find | ( | const T & | x | ) | const [inline] |
Find element x in the array.
x | The element to seach for. |
Definition at line 378 of file ArrayImpl.hpp.
Array< T >::reference BLOCXX_NAMESPACE::Array< T >::front | ( | ) | [inline] |
Definition at line 223 of file ArrayImpl.hpp.
References m_impl.
Array< T >::const_reference BLOCXX_NAMESPACE::Array< T >::front | ( | ) | const [inline] |
Definition at line 230 of file ArrayImpl.hpp.
References m_impl.
Array< T >::iterator BLOCXX_NAMESPACE::Array< T >::insert | ( | iterator | position, |
const T & | x | ||
) | [inline] |
Insert an element in the Array before an element specified by an iterator.
position | An iterator that points to the insertion point. The element will be inserted before this point. |
x | The element to insert into the Array. |
Definition at line 272 of file ArrayImpl.hpp.
References m_impl.
void BLOCXX_NAMESPACE::Array< T >::insert | ( | size_type | position, |
const T & | x | ||
) | [inline] |
Insert an element in the Array before an element specified by an index.
position | An index that specifies where the element will be inserted. |
x | The element to insert into the Array. |
Definition at line 279 of file ArrayImpl.hpp.
References m_impl.
void BLOCXX_NAMESPACE::Array< T >::insert | ( | iterator | position, |
InputIterator | first, | ||
InputIterator | last | ||
) | [inline] |
Insert a range of elements before a given position in the Array.
position | The position to insert the elements at. The insertion will be done before this position. |
first | The beginning of the range of elements to insert. |
last | The end of the range of elements to insert. |
Definition at line 308 of file ArrayImpl.hpp.
References m_impl.
Array< T >::size_type BLOCXX_NAMESPACE::Array< T >::max_size | ( | ) | const [inline] |
Definition at line 167 of file ArrayImpl.hpp.
References m_impl.
Array< T > & BLOCXX_NAMESPACE::Array< T >::operator+= | ( | const T & | x | ) | [inline] |
Array< T >::reference BLOCXX_NAMESPACE::Array< T >::operator[] | ( | size_type | n | ) | [inline] |
Retrieve A read/write reference to an object in the Array at a given index.
n | The index of the element to retrieve the reference for. |
Definition at line 188 of file ArrayImpl.hpp.
References m_impl.
Array< T >::const_reference BLOCXX_NAMESPACE::Array< T >::operator[] | ( | size_type | n | ) | const [inline] |
Retrieve A read only reference to an object in the Array at a given index.
n | The index of the element to retrieve the reference for. |
Definition at line 198 of file ArrayImpl.hpp.
References m_impl.
void BLOCXX_NAMESPACE::Array< T >::pop_back | ( | ) | [inline] |
Remove the last element of the Array.
Definition at line 322 of file ArrayImpl.hpp.
References m_impl.
Referenced by BLOCXX_NAMESPACE::Stack< T >::pop().
void BLOCXX_NAMESPACE::Array< T >::push_back | ( | const T & | x | ) | [inline] |
Append an element to the end of the Array.
x | The element to append to the end of the Array. |
Definition at line 251 of file ArrayImpl.hpp.
References m_impl.
Referenced by BLOCXX_NAMESPACE::CmdLineParser::CmdLineParser(), BLOCXX_NAMESPACE::SocketBaseImpl::connect(), BLOCXX_NAMESPACE::StackTrace::getStackTrace(), BLOCXX_NAMESPACE::SelectEngine::go(), BLOCXX_NAMESPACE::Stack< T >::push(), BLOCXX_NAMESPACE::Select::select(), and BLOCXX_NAMESPACE::SocketUtils::waitForIO().
Array< T >::reverse_iterator BLOCXX_NAMESPACE::Array< T >::rbegin | ( | ) | [inline] |
Definition at line 132 of file ArrayImpl.hpp.
References m_impl.
Array< T >::const_reverse_iterator BLOCXX_NAMESPACE::Array< T >::rbegin | ( | ) | const [inline] |
Definition at line 139 of file ArrayImpl.hpp.
References m_impl.
void BLOCXX_NAMESPACE::Array< T >::remove | ( | size_type | index | ) | [inline] |
Remove an element from the Array at a given index.
Definition at line 286 of file ArrayImpl.hpp.
References m_impl.
void BLOCXX_NAMESPACE::Array< T >::remove | ( | size_type | begin, |
size_type | end | ||
) | [inline] |
Remove an element specified by a range.
begin | An iterator that specifies the beginning of the range to remove. |
end | An iterator that specifies the end of the range to remove. |
Definition at line 296 of file ArrayImpl.hpp.
References m_impl.
Array< T >::const_reverse_iterator BLOCXX_NAMESPACE::Array< T >::rend | ( | ) | const [inline] |
Definition at line 153 of file ArrayImpl.hpp.
References m_impl.
Array< T >::reverse_iterator BLOCXX_NAMESPACE::Array< T >::rend | ( | ) | [inline] |
Definition at line 146 of file ArrayImpl.hpp.
References m_impl.
void BLOCXX_NAMESPACE::Array< T >::reserve | ( | size_type | n | ) | [inline] |
Ensure the capacity is at least the size of a given value.
If the given value is > max_size() the method with throw an std::length_error exception.
n | - The minimum size this Array can be. |
Definition at line 216 of file ArrayImpl.hpp.
References m_impl.
Referenced by BLOCXX_NAMESPACE::DelayedFormat::DelayedFormat(), and BLOCXX_NAMESPACE::Select::select().
void BLOCXX_NAMESPACE::Array< T >::resize | ( | size_type | new_size | ) | [inline] |
Ensure the Array is a given size.
If the Array needs to be larger that what it already is, this method will append items that have been initialized using the default constructor of class T.
new_size | The new size of the Array. |
Definition at line 350 of file ArrayImpl.hpp.
References m_impl.
void BLOCXX_NAMESPACE::Array< T >::resize | ( | size_type | new_size, |
const T & | x | ||
) | [inline] |
Array< T >::size_type BLOCXX_NAMESPACE::Array< T >::size | ( | ) | const [inline] |
Reimplemented in BLOCXX_NAMESPACE::Stack< T >.
Definition at line 160 of file ArrayImpl.hpp.
References m_impl.
Referenced by BLOCXX_NAMESPACE::SocketBaseImpl::connect(), BLOCXX_NAMESPACE::DateTime::DateTime(), BLOCXX_NAMESPACE::SyslogAppender::doProcessLogMessage(), BLOCXX_NAMESPACE::MultiAppender::doProcessLogMessage(), BLOCXX_NAMESPACE::DelayedFormat::formatWithString(), BLOCXX_NAMESPACE::CmdLineParser::getNonOptionCount(), BLOCXX_NAMESPACE::SelectEngine::go(), BLOCXX_NAMESPACE::Exec::processInputOutput(), BLOCXX_NAMESPACE::Select::select(), BLOCXX_NAMESPACE::Select::selectRWEpoll(), BLOCXX_NAMESPACE::Select::selectRWPoll(), BLOCXX_NAMESPACE::Select::selectRWSelect(), BLOCXX_NAMESPACE::String::String(), and BLOCXX_NAMESPACE::UTF8Utils::UCS2ToString().
void BLOCXX_NAMESPACE::Array< T >::swap | ( | Array< T > & | x | ) | [inline] |
Swap the elements of this Array with the elements of another.
Definition at line 265 of file ArrayImpl.hpp.
References BLOCXX_NAMESPACE::Array< T >::m_impl, m_impl, and BLOCXX_NAMESPACE::IntrusiveReference< T >::swap().
Referenced by BLOCXX_NAMESPACE::swap().
Determine if one Array is less than another.
This is done by doing a lexicographical compare on the Arrays. a lexicographical compare will compares the Arrays element by element until:
Determine equality of two Arrays.
Two Arrays are considered equal if they are of the same size and elements in the same position are equal as defined by the “==” operator of the type in the Array.
COWReference<V> BLOCXX_NAMESPACE::Array< T >::m_impl [private] |
Definition at line 74 of file Array.hpp.
Referenced by BLOCXX_NAMESPACE::operator<(), BLOCXX_NAMESPACE::operator==(), and BLOCXX_NAMESPACE::Array< T >::swap().