Doxygen
|
std::vector like container optimized for pushing elements to the back. More...
#include <src/growvector.h>
Classes | |
struct | Chunk |
class | Iterator |
bidirectional iterator More... | |
Public Types | |
using | iterator = Iterator<GrowVector,T> |
using | const_iterator = Iterator<const GrowVector,const T> |
Public Member Functions | |
iterator | begin () |
returns an iterator to the beginning | |
const_iterator | begin () const |
returns an iterator to the beginning | |
iterator | end () |
returns an iterator to the end | |
const_iterator | end () const |
returns an iterator to the end | |
size_t | size () const |
returns the number of elements | |
void | push_back (T &&t) |
adds an element to the end | |
template<class... Args> | |
void | emplace_back (Args &&...args) |
constructs an element in-place at the end | |
void | pop_back () |
removes the last element | |
T & | at (size_t i) |
access specified element | |
const T & | at (size_t i) const |
access specified element | |
T & | front () |
access the first element | |
const T & | front () const |
access the first element | |
T & | back () |
access the last element | |
const T & | back () const |
access the last element | |
bool | empty () const |
checks whether the container is empty | |
void | clear () |
clears the contents | |
Private Types | |
using | ChunkPtr = std::unique_ptr<Chunk> |
Private Member Functions | |
void | make_room () |
Private Attributes | |
std::vector< ChunkPtr > | m_chunks |
Static Private Attributes | |
static const size_t | chunkBits = 4 |
static const size_t | chunkSize = 1 << chunkBits |
static const size_t | chunkMask = chunkSize-1 |
std::vector like container optimized for pushing elements to the back.
It differs from std::vector in that it can grow without invalidating pointers to its members just like std::deque and std::list.
It differs from std::deque in that the value can be incomplete just like std::vector.
It differs from std::list in that it does not need to allocate each node separately and provides random access to its members.
It is implemented as a vector of chunks where each chunk is a fixed capacity vector of T.
Definition at line 39 of file growvector.h.
|
private |
Definition at line 50 of file growvector.h.
using GrowVector< T >::const_iterator = Iterator<const GrowVector,const T> |
Definition at line 80 of file growvector.h.
using GrowVector< T >::iterator = Iterator<GrowVector,T> |
Definition at line 79 of file growvector.h.
|
inline |
access specified element
Definition at line 125 of file growvector.h.
|
inline |
|
inline |
access the last element
Definition at line 135 of file growvector.h.
References m_chunks.
Referenced by DocPara::handleHtmlStartTag(), DocParser::handleStyleEnter(), and DocParser::internalValidatingParseDoc().
|
inline |
|
inline |
|
inline |
returns an iterator to the beginning
Definition at line 85 of file growvector.h.
|
inline |
clears the contents
Definition at line 143 of file growvector.h.
References m_chunks.
Referenced by flattenParagraphs(), and DocNodeList::move_append().
|
inline |
constructs an element in-place at the end
Definition at line 108 of file growvector.h.
References m_chunks, and make_room().
|
inline |
checks whether the container is empty
Definition at line 140 of file growvector.h.
References m_chunks.
Referenced by DocParser::defaultHandleToken(), DocDiagramFileBase::hasCaption(), DocImage::hasCaption(), DocVhdlFlow::hasCaption(), DocRef::hasLinkText(), DocTitle::hasTitle(), DocParser::internalValidatingParseDoc(), DocPara::isEmpty(), DocRoot::isEmpty(), DocText::isEmpty(), DocHtmlRow::isHeading(), DocbookDocVisitor::operator()(), DocbookDocVisitor::operator()(), HtmlDocVisitor::operator()(), PrintDocVisitor::operator()(), XmlDocVisitor::operator()(), DocParamSect::parse(), DocSimpleSect::parse(), and DocSimpleSect::parseXml().
|
inline |
returns an iterator to the end
Definition at line 88 of file growvector.h.
References size().
Referenced by DocPara::handleIncludeOperator().
|
inline |
|
inline |
access the first element
Definition at line 130 of file growvector.h.
References m_chunks.
Referenced by DocHtmlTable::firstRow(), and DocbookDocVisitor::operator()().
|
inline |
|
inlineprivate |
Definition at line 146 of file growvector.h.
References chunkSize, and m_chunks.
Referenced by emplace_back(), and push_back().
|
inline |
removes the last element
Definition at line 115 of file growvector.h.
References m_chunks.
Referenced by DocPara::handleCommand(), DocPara::handleFile(), DocPara::handleXRefItem(), DocParser::internalValidatingParseDoc(), DocAutoListItem::parse(), DocInternal::parse(), DocRoot::parse(), and DocSection::parse().
|
inline |
adds an element to the end
Definition at line 100 of file growvector.h.
References m_chunks, and make_room().
|
inline |
returns the number of elements
Definition at line 93 of file growvector.h.
References chunkSize, and m_chunks.
Referenced by end(), end(), DocPara::handleIncludeOperator(), DocHtmlRow::numCells(), and DocHtmlTable::numRows().
|
staticprivate |
Definition at line 42 of file growvector.h.
|
staticprivate |
Definition at line 44 of file growvector.h.
|
staticprivate |
Definition at line 43 of file growvector.h.
Referenced by GrowVector< T >::Chunk::Chunk(), make_room(), and size().
|
private |
Definition at line 154 of file growvector.h.
Referenced by at(), at(), back(), back(), clear(), emplace_back(), empty(), front(), front(), make_room(), pop_back(), push_back(), and size().