RAPIDJSON_DIAG_OFF(c++98-compat)
35 template<
typenameAllocator>
40 Stack(
Allocator* allocator,
size_tstackCapacity) : allocator_(allocator), ownAllocator_(0), stack_(0), stackTop_(0), stackEnd_(0), initialCapacity_(stackCapacity) {
43 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 45: allocator_(rhs.allocator_),
46ownAllocator_(rhs.ownAllocator_),
48stackTop_(rhs.stackTop_),
49stackEnd_(rhs.stackEnd_),
50initialCapacity_(rhs.initialCapacity_)
53rhs.ownAllocator_ = 0;
57rhs.initialCapacity_ = 0;
65 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 71allocator_ = rhs.allocator_;
72ownAllocator_ = rhs.ownAllocator_;
74stackTop_ = rhs.stackTop_;
75stackEnd_ = rhs.stackEnd_;
76initialCapacity_ = rhs.initialCapacity_;
79rhs.ownAllocator_ = 0;
83rhs.initialCapacity_ = 0;
98 void Clear() { stackTop_ = stack_; }
114 template<
typenameT>
121 template<
typenameT>
124 returnPushUnsafe<T>(
count);
127 template<
typenameT>
131 T* ret =
reinterpret_cast<T*
>(stackTop_);
132stackTop_ +=
sizeof(
T) *
count;
136 template<
typenameT>
139stackTop_ -=
count*
sizeof(
T);
140 return reinterpret_cast<T*
>(stackTop_);
143 template<
typenameT>
146 return reinterpret_cast<T*
>(stackTop_ -
sizeof(
T));
149 template<
typenameT>
152 return reinterpret_cast<T*
>(stackTop_ -
sizeof(
T));
155 template<
typenameT>
156 T*
End() {
return reinterpret_cast<T*
>(stackTop_); }
158 template<
typenameT>
159 const T*
End()
const{
return reinterpret_cast<T*
>(stackTop_); }
161 template<
typenameT>
162 T*
Bottom() {
return reinterpret_cast<T*
>(stack_); }
164 template<
typenameT>
165 const T*
Bottom()
const{
return reinterpret_cast<T*
>(stack_); }
168 returnallocator_ != 0;
176 bool Empty()
const{
returnstackTop_ == stack_; }
177 size_t GetSize()
const{
return static_cast<size_t>(stackTop_ - stack_); }
178 size_t GetCapacity()
const{
return static_cast<size_t>(stackEnd_ - stack_); }
181 template<
typenameT>
188newCapacity = initialCapacity_;
190newCapacity = GetCapacity();
191newCapacity += (newCapacity + 1) / 2;
193 size_tnewSize = GetSize() +
sizeof(
T) *
count;
194 if(newCapacity < newSize)
195newCapacity = newSize;
201 const size_t size= GetSize();
202stack_ =
static_cast<char*
>(allocator_->Realloc(stack_, GetCapacity(), newCapacity));
203stackTop_ = stack_ +
size;
204stackEnd_ = stack_ + newCapacity;
227 #if defined(__clang__)Concept for allocating, resizing and freeing memory block.
A type-unsafe stack for storing different types of data.
bool HasAllocator() const
size_t GetCapacity() const
void Expand(size_t count)
RAPIDJSON_FORCEINLINE void Reserve(size_t count=1)
Allocator * ownAllocator_
Stack & operator=(const Stack &)
RAPIDJSON_FORCEINLINE T * Push(size_t count=1)
void Resize(size_t newCapacity)
Stack(Allocator *allocator, size_t stackCapacity)
Allocator & GetAllocator()
void Swap(Stack &rhs) RAPIDJSON_NOEXCEPT
RAPIDJSON_FORCEINLINE T * PushUnsafe(size_t count=1)
bool Empty(const CNcbiOstrstream &src)
#define RAPIDJSON_UNLIKELY(x)
Compiler branching hint for expression with low probability to be true.
#define RAPIDJSON_ASSERT(x)
Assertion.
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
const struct ncbi::grid::netcache::search::fields::SIZE size
void Swap(T &a, T &b) RAPIDJSON_NOEXCEPT
Custom swap() to avoid dependency on C++ <algorithm> header.
#define RAPIDJSON_DELETE(x)
! customization point for global delete
#define RAPIDJSON_NEW(TypeName)
! customization point for global new
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4