3 #ifndef INCLUDE_NN_NLIB_NLIST_H_ 4 #define INCLUDE_NN_NLIB_NLIST_H_ 13 #include "nn/nlib/Swap.h" 18 template <
class T,
class AL>
36 return 8 * ((1 << level) - 1);
39 return 8 * (1 << level);
42 bool ConfirmBack() const NLIB_NOEXCEPT;
43 void ClearSimple() NLIB_NOEXCEPT {
52 mutable size_t curlevel_;
53 mutable size_t curidx_;
54 mutable Blk* firstblk_;
61 class NlistConstIterator;
66 class NlistBaseT :
public NlistBase {
69 typedef const T& const_reference;
70 typedef NlistIterator<T> iterator;
71 typedef NlistConstIterator<T> const_iterator;
72 typedef size_t size_type;
75 typedef const T* const_pointer;
76 typedef ptrdiff_t difference_type;
81 return reinterpret_cast<T*
>(blk->item);
84 return reinterpret_cast<const T*
>(blk->item);
88 const Blk* p = this->AtSub(n, &base);
89 return p ?
const_cast<T*
>(&(GetItem(p)[n - base])) : NULL;
91 iterator Begin()
NLIB_NOEXCEPT {
return iterator(
this, TrueType()); }
92 iterator End()
NLIB_NOEXCEPT {
return iterator(
this, FalseType()); }
94 return const_iterator(
this, TrueType());
97 return const_iterator(
this, FalseType());
102 friend class NlistConstIterator<T>;
103 friend class NlistIterator<T>;
107 class NlistConstIterator
108 :
public std::iterator<std::forward_iterator_tag, T> {
110 typedef NlistBaseT<T> ContainerType;
111 typedef typename ContainerType::Blk Blk;
114 typedef typename std::iterator<std::forward_iterator_tag, T> BaseType;
115 typedef typename BaseType::iterator_category iterator_category;
116 typedef typename BaseType::value_type value_type;
117 typedef typename BaseType::difference_type difference_type;
118 typedef typename BaseType::pointer pointer;
119 typedef typename BaseType::reference reference;
128 NlistConstIterator(
const ContainerType* p, TrueType)
NLIB_NOEXCEPT {
129 ContainerType* rhs =
const_cast<ContainerType*
>(p);
131 blk_ = rhs->firstblk_;
132 elemptr_ = GetItem(blk_);
133 blkend_ = elemptr_ + 8;
135 NlistConstIterator(
const ContainerType* p, FalseType)
NLIB_NOEXCEPT {
136 ContainerType* rhs =
const_cast<ContainerType*
>(p);
137 idx_ = rhs->BlkBaseIdx(rhs->curlevel_) + rhs->curidx_;
139 elemptr_ = &(GetItem(blk_)[rhs->curidx_]);
140 blkend_ = GetItem(blk_) + rhs->BlkSize(rhs->curlevel_);
141 if (elemptr_ == blkend_) this->Normalize();
145 const T&
operator*() const NLIB_NOEXCEPT {
return *elemptr_; }
146 const T* operator->() const NLIB_NOEXCEPT {
return elemptr_; }
147 NlistConstIterator& operator++() NLIB_NOEXCEPT {
148 NLIB_ASSERT(elemptr_ != blkend_);
150 if (++elemptr_ == blkend_) this->Normalize();
153 NlistConstIterator operator++(
int) NLIB_NOEXCEPT {
154 NlistConstIterator rval(*
this);
158 bool operator==(
const NlistConstIterator& rhs)
const NLIB_NOEXCEPT {
159 return idx_ == rhs.idx_ && elemptr_ == rhs.elemptr_;
161 bool operator!=(
const NlistConstIterator& rhs)
const NLIB_NOEXCEPT {
165 difference_type Distance(NlistConstIterator to)
const NLIB_NOEXCEPT {
166 return to.idx_ - idx_;
170 static T* GetItem(Blk* blk) NLIB_NOEXCEPT {
171 return reinterpret_cast<T*
>(blk->item);
173 static const T* GetItem(
const Blk* blk) NLIB_NOEXCEPT {
174 return reinterpret_cast<const T*
>(blk->item);
176 bool Normalize() NLIB_NOEXCEPT;
183 friend class NlistBaseT<T>;
187 bool NlistConstIterator<T>::Normalize() NLIB_NOEXCEPT {
188 if (blk_ && blk_->next) {
189 Blk* next = blk_->next;
190 size_t next_size = 2 *
static_cast<size_t>(blkend_ - GetItem(blk_));
191 T* next_elemptr = GetItem(next);
192 T* next_end = next_elemptr + next_size;
194 elemptr_ = next_elemptr;
202 void NlistConstIterator<T>::Advance(difference_type n) NLIB_NOEXCEPT {
203 while (elemptr_ + n >= blkend_) {
204 n -= blkend_ - elemptr_;
205 idx_ += blkend_ - elemptr_;
207 if (!this->Normalize())
return;
214 class NlistIterator :
public NlistConstIterator<T> {
216 typedef NlistBaseT<T> ContainerType;
217 typedef typename ContainerType::Blk Blk;
218 typedef NlistConstIterator<T> MyBase;
221 typedef typename NlistConstIterator<T>::BaseType BaseType;
222 typedef typename BaseType::iterator_category iterator_category;
223 typedef typename BaseType::value_type value_type;
224 typedef typename BaseType::difference_type difference_type;
225 typedef typename BaseType::pointer pointer;
226 typedef typename BaseType::reference reference;
229 NLIB_CEXPR NlistIterator() NLIB_NOEXCEPT : MyBase() {}
232 NlistIterator(
const ContainerType* p, TrueType) NLIB_NOEXCEPT : MyBase(p, TrueType()) {}
233 NlistIterator(
const ContainerType* p, FalseType) NLIB_NOEXCEPT : MyBase(p, FalseType()) {}
237 const MyBase* tmp =
static_cast<const MyBase*
>(
this);
238 return const_cast<T&
>(**tmp);
240 T* operator->() const NLIB_NOEXCEPT {
241 const MyBase* tmp =
static_cast<const MyBase*
>(
this);
242 return const_cast<T*
>(tmp->operator->());
244 NlistIterator& operator++() NLIB_NOEXCEPT {
245 MyBase* tmp =
static_cast<MyBase*
>(
this);
249 NlistIterator operator++(
int) NLIB_NOEXCEPT {
250 NlistIterator rval(*
this);
254 bool operator==(
const NlistIterator& rhs)
const NLIB_NOEXCEPT {
255 const MyBase* tmp =
static_cast<const MyBase*
>(
this);
256 const MyBase* tmp2 =
static_cast<const MyBase*
>(&rhs);
257 return *tmp == *tmp2;
259 bool operator!=(
const NlistIterator& rhs)
const NLIB_NOEXCEPT {
262 difference_type Distance(NlistIterator to)
const NLIB_NOEXCEPT {
263 const MyBase* tmp =
static_cast<const MyBase*
>(
this);
264 const MyBase* tmp2 =
static_cast<const MyBase*
>(&to);
265 return tmp->Distance(*tmp2);
269 friend class NlistBaseT<T>;
272 template<
bool is_empty,
class AL>
275 NlistAlloc() NLIB_NOEXCEPT : alloc_(AL()) {}
276 explicit NlistAlloc(
const AL& al) NLIB_NOEXCEPT : alloc_(al) {}
279 AL& _GetNlistAlloc() const NLIB_NOEXCEPT {
280 return const_cast<AL&
>(alloc_);
282 void _SwapNlistAlloc(NlistAlloc& rhs) NLIB_NOEXCEPT {
284 swap(alloc_, rhs.alloc_);
292 class NlistAlloc <true, AL> {
294 NlistAlloc() NLIB_NOEXCEPT {}
295 explicit NlistAlloc(
const AL& al) NLIB_NOEXCEPT { NLIB_UNUSED(al); }
298 AL _GetNlistAlloc() const NLIB_NOEXCEPT {
return AL(); }
299 void _SwapNlistAlloc(NlistAlloc& rhs) NLIB_NOEXCEPT {
306 template <
class T,
class AL = std::allocator<
char> >
307 class Nlist :
public nlist::NlistBaseT<T>,
308 public nlist::NlistAlloc<IsEmpty<AL>::value, AL> {
333 typedef typename nlist::NlistBaseT<T> BaseType;
334 typedef typename nlist::NlistAlloc<IsEmpty<AL>::value, AL> AllocType;
335 using BaseType::curblk_;
336 using BaseType::curidx_;
337 using BaseType::curlevel_;
338 using BaseType::firstblk_;
339 using BaseType::ConfirmBack;
340 using BaseType::ClearSimple;
341 using BaseType::BlkBaseIdx;
342 using BaseType::BlkSize;
343 using BaseType::GetItem;
344 using BaseType::Begin;
346 typedef typename BaseType::Blk Blk;
361 Nlist() NLIB_NOEXCEPT : AllocType(AL()) {}
362 explicit Nlist(
const AL& al) NLIB_NOEXCEPT : AllocType(al) {}
364 NLIB_MOVE_MEMBER_HELPER_2(
Nlist, BaseType, AllocType)
365 size_type size() const NLIB_NOEXCEPT {
366 return BlkBaseIdx(curlevel_) + curidx_;
370 return (NULL != this->LastBlock(&lv)) ? BlkBaseIdx(lv + 1) : 0;
372 bool empty() const NLIB_NOEXCEPT {
return curlevel_ == 0 && curidx_ == 0; }
374 return Resize(n,
typename IsTriviallyDefaultConstructible<T>::type());
378 void* p = this->PushBack();
380 pointer ptr = MyCtor(p,
typename IsTriviallyDefaultConstructible<T>::type());
384 #ifdef NLIB_CXX11_RVALUE_REFERENCES 385 pointer push_back(T&& rhs) NLIB_NOEXCEPT {
386 #if defined(NLIB_HAS_NATIVE_TYPETRAITS) && !defined(NLIB_HAS_TR1_TYPETRAITS) 389 void* p = this->PushBack();
391 pointer ptr =
new (p) T(std::forward<T>(rhs));
396 pointer push_back(
const T& rhs) {
397 void* p = this->PushBack();
399 pointer ptr =
new (p) T(rhs);
404 return this->pop_back_(
typename IsTriviallyDestructible<T>::type());
409 swap(curblk_, rhs.curblk_);
410 swap(curlevel_, rhs.curlevel_);
411 swap(curidx_, rhs.curidx_);
412 swap(firstblk_, rhs.firstblk_);
413 AllocType::_SwapNlistAlloc(rhs);
416 Clear(
typename IsTriviallyDestructible<T>::type());
419 return AllocType::_GetNlistAlloc();
423 if (curidx_ == 0) ConfirmBack();
424 return GetItem(curblk_)[curidx_ - 1];
427 if (curidx_ == 0) ConfirmBack();
428 return GetItem(curblk_)[curidx_ - 1];
430 const_reference
front()
const {
return GetItem(firstblk_)[0]; }
431 reference
front() {
return GetItem(firstblk_)[0]; }
433 NLIB_ASSERT(idx < this->size());
434 return *this->At(idx);
437 NLIB_ASSERT(idx < this->size());
438 return *this->At(idx);
442 if (!firstblk_ && !ConfirmFirstBlk())
return iterator();
445 const_iterator
begin() const NLIB_NOEXCEPT {
446 if (!firstblk_ && !ConfirmFirstBlk())
return const_iterator();
449 const_iterator
cbegin() const NLIB_NOEXCEPT {
450 if (!firstblk_ && !ConfirmFirstBlk())
return const_iterator();
454 iterator
end() NLIB_NOEXCEPT {
455 if (!firstblk_ && !ConfirmFirstBlk())
return iterator();
458 const_iterator
end() const NLIB_NOEXCEPT {
459 if (!firstblk_ && !ConfirmFirstBlk())
return const_iterator();
462 const_iterator
cend() const NLIB_NOEXCEPT {
463 if (!firstblk_ && !ConfirmFirstBlk())
return const_iterator();
468 if (!curblk_)
return;
469 Blk* p = curblk_->next;
470 curblk_->next = NULL;
471 DeallocBlkList(p, static_cast<int>(curlevel_ + 1));
473 #if defined(NLIB_CXX11_RVALUE_REFERENCES) && defined(NLIB_CXX11_VARIADIC_TEMPLATES) 474 template<
class... Args>
475 pointer EmplaceBack(Args&&... args) {
476 void* p = this->PushBack();
478 pointer ptr =
new (p) T(std::forward<Args>(args)...);
485 void* p = this->PushBack();
487 pointer ptr =
new (p) T(
const_cast<typename RemoveConst<A1>::type&
>(a1));
491 template <
class A1,
class A2>
493 void* p = this->PushBack();
495 pointer ptr =
new (p) T(
const_cast<typename RemoveConst<A1>::type&
>(a1),
496 const_cast<typename RemoveConst<A2>::type&
>(a2));
500 template <
class A1,
class A2,
class A3>
502 void* p = this->PushBack();
504 pointer ptr =
new (p) T(
const_cast<typename RemoveConst<A1>::type&
>(a1),
505 const_cast<typename RemoveConst<A2>::type&
>(a2),
506 const_cast<typename RemoveConst<A3>::type&
>(a3));
510 template <
class A1,
class A2,
class A3,
class A4>
511 pointer
EmplaceBack(
const A1& a1,
const A2& a2,
const A3& a3,
const A4& a4) {
512 void* p = this->PushBack();
514 pointer ptr =
new (p) T(
const_cast<typename RemoveConst<A1>::type&
>(a1),
515 const_cast<typename RemoveConst<A2>::type&
>(a2),
516 const_cast<typename RemoveConst<A3>::type&
>(a3),
517 const_cast<typename RemoveConst<A4>::type&
>(a4));
521 template <
class A1,
class A2,
class A3,
class A4,
class A5>
523 EmplaceBack(
const A1& a1,
const A2& a2,
const A3& a3,
const A4& a4,
const A5& a5) {
524 void* p = this->PushBack();
526 pointer ptr =
new (p) T(
const_cast<typename RemoveConst<A1>::type&
>(a1),
527 const_cast<typename RemoveConst<A2>::type&
>(a2),
528 const_cast<typename RemoveConst<A3>::type&
>(a3),
529 const_cast<typename RemoveConst<A4>::type&
>(a4),
530 const_cast<typename RemoveConst<A5>::type&
>(a5));
546 void DestroyBlk(Blk*,
size_t, TrueType)
const NLIB_NOEXCEPT {}
547 void DestroyBlk(Blk* p,
size_t n, FalseType)
const NLIB_NOEXCEPT;
548 void DestroyBlk(Blk* p,
size_t n)
const NLIB_NOEXCEPT {
549 DestroyBlk(p, n,
typename IsTriviallyDestructible<T>::type());
554 void Clear(TrueType) NLIB_NOEXCEPT { ClearSimple(); }
557 T* MyCtor(
void* p, TrueType) NLIB_NOEXCEPT {
558 return reinterpret_cast<T*
>(p);
560 T* MyCtor(
void* p, FalseType) {
564 bool pop_back_(FalseType) NLIB_NOEXCEPT {
566 if (!ConfirmBack())
return false;
568 reference item = GetItem(curblk_)[--curidx_];
573 bool pop_back_(TrueType) NLIB_NOEXCEPT {
575 if (!ConfirmBack())
return false;
585 template <
class T,
class AL>
588 this->DeallocBlkList(firstblk_, 0);
593 template <
class T,
class AL>
594 class ResizeRewinder {
596 ResizeRewinder(
Nlist<T, AL>& l) NLIB_NOEXCEPT : count_(0), list_(l) {}
597 void PushBack(
size_t n) {
598 for (; count_ < n; ++count_) {
603 ~ResizeRewinder() NLIB_NOEXCEPT {
604 for (; count_ > 0; --count_) {
617 template <
class T,
class AL>
620 size_t sz = this->size();
621 if (n == sz)
return true;
623 for (
size_t i = sz; i > n; --i) {
627 if (!this->reserve(n))
return false;
628 nlist::ResizeRewinder<T, AL> rewinder(*
this);
629 rewinder.PushBack(n);
634 template <
class T,
class AL>
636 size_type sz = this->size();
637 if (n == sz)
return true;
639 for (size_type i = sz; i > n; --i) {
643 if (!this->reserve(n))
return false;
647 size_t lower = this->BlkBaseIdx(curlevel_);
648 size_t upper = this->BlkBaseIdx(curlevel_ + 1);
651 curblk_ = curblk_->next;
653 upper = this->BlkBaseIdx(curlevel_ + 1);
655 curidx_ =
static_cast<size_t>(n - lower);
660 template <
class T,
class AL>
662 if (n == 0 || n <= BlkBaseIdx(curlevel_ + 1))
return true;
663 if (!firstblk_ && !this->ConfirmFirstBlk())
return false;
665 Blk* blk = this->LastBlock(&lv);
667 if (n <= BlkBaseIdx(lv + 1))
return true;
669 Blk* p = this->AllocBlk(BlkSize(lv));
670 if (!p)
return false;
676 template <
class T,
class AL>
681 size_t sz =
sizeof(Blk) + n *
sizeof(T);
684 pp = AllocType::_GetNlistAlloc().allocate(sz);
686 #ifdef NLIB_EXCEPTION_ENABLED 687 NLIB_CATCH(
const std::bad_alloc&) {
return NULL; }
689 if (!pp)
return NULL;
690 Blk* p =
reinterpret_cast<Blk*
>(pp);
692 p->item =
reinterpret_cast<T*
>(p + 1);
696 template <
class T,
class AL>
699 size_t n = BlkSize(lv);
704 AllocType::_GetNlistAlloc().deallocate(reinterpret_cast<char*>(pp),
705 sizeof(Blk) + n *
sizeof(T));
710 template <
class T,
class AL>
715 T* base =
reinterpret_cast<T*
>(p->item);
717 for (
size_t i = 0; i < n; ++i) {
722 template <
class T,
class AL>
724 Blk* p = AllocBlk(BlkSize(0));
725 if (!p)
return false;
733 template <
class T,
class AL>
735 if (!firstblk_ && !ConfirmFirstBlk())
return NULL;
736 if (curidx_ == BlkSize(curlevel_)) {
737 if (!curblk_->next) {
738 Blk* p = AllocBlk(BlkSize(curlevel_ + 1));
743 curblk_ = curblk_->next;
750 T& item = GetItem(curblk_)[curidx_];
754 template <
class T,
class AL>
759 while (p != curblk_) {
760 size_t cnt = BlkSize(lv);
766 DestroyBlk(p, curidx_);
771 template <
class T,
class AL1,
class AL2>
774 return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin());
777 template <
class T,
class AL1,
class AL2>
780 return !(lhs == rhs);
783 template <
class T,
class AL1,
class AL2>
784 inline bool operator<(const Nlist<T, AL1>& lhs,
786 return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
789 template <
class T,
class AL1,
class AL2>
795 template <
class T,
class AL1,
class AL2>
796 inline bool operator<=(const Nlist<T, AL1>& lhs,
798 return (!(rhs < lhs));
801 template <
class T,
class AL1,
class AL2>
804 return (!(lhs < rhs));
807 template <
class AL = std::allocator<
char> >
812 typedef AL allocator_type;
813 typedef typename ContainerType::iterator iterator;
814 typedef typename ContainerType::const_iterator const_iterator;
817 StringList() NLIB_NOEXCEPT : list_() {}
818 explicit StringList(
const AL& al) : list_(al) {}
820 size_t size()
const NLIB_NOEXCEPT {
return list_.size(); }
821 size_t capacity()
const NLIB_NOEXCEPT {
return list_.capacity(); }
822 bool empty()
const NLIB_NOEXCEPT {
return list_.empty(); }
823 bool reserve(
size_t n) {
return list_.reserve(n); }
824 bool resize(
size_t n) {
return list_.resize(n); }
826 char** push_back(
const char* str);
827 template <
class Iterator>
828 char** push_back(Iterator first, Iterator last);
831 void swap(StringList& rhs) NLIB_NOEXCEPT { list_.swap(rhs.list_); }
832 void clear() NLIB_NOEXCEPT { list_.clear(); }
833 allocator_type get_allocator()
const {
return list_.get_allocator(); }
835 const char* back()
const {
return list_.back(); }
836 char* back() {
return list_.back(); }
837 const char* front()
const {
return list_.front(); }
838 char* front() {
return list_.front(); }
839 const char* operator[](
size_t idx)
const {
return list_[idx]; }
840 char* operator[](
size_t idx) {
return list_[idx]; }
841 iterator begin() NLIB_NOEXCEPT {
return list_.begin(); }
842 const_iterator begin()
const NLIB_NOEXCEPT {
return list_.begin(); }
843 const_iterator cbegin() NLIB_NOEXCEPT {
return list_.cbegin(); }
845 iterator end() NLIB_NOEXCEPT {
return list_.end(); }
846 const_iterator end()
const NLIB_NOEXCEPT {
return list_.end(); }
847 const_iterator cend() NLIB_NOEXCEPT {
return list_.cend(); }
849 void shrink_to_fit() { list_.shrink_to_fit(); }
850 void Clobber() NLIB_NOEXCEPT { list_.clobber(); }
852 char** Replace(iterator it,
const char* str);
853 char** Replace(
size_t idx,
const char* str) {
854 if (idx >= list_.size())
return NULL;
855 iterator it = list_.begin();
857 return this->Replace(it, str);
861 void Dealloc(
const char* ptr)
const {
864 this->get_allocator().deallocate(const_cast<char*>(ptr), 0);
867 char* StrDup(
const char* ptr)
const;
868 char* Alloc(
size_t nbytes)
const {
869 return this->get_allocator().allocate(nbytes);
878 char* StringList<AL>::StrDup(
const char* ptr)
const {
880 void* p = this->Alloc(nbytes);
883 return reinterpret_cast<char*
>(p);
887 StringList<AL>::~StringList() NLIB_NOEXCEPT {
888 const_iterator it = this->cbegin();
889 const_iterator it_end = this->cend();
890 while (it != it_end) {
897 char** StringList<AL>::push_back(
const char* str) {
900 dup = this->StrDup(str);
901 if (!dup)
return NULL;
905 char** ptr_str = list_.push_back(dup);
906 if (!ptr_str) this->Dealloc(dup);
911 template <
class Iterator>
912 char** StringList<AL>::push_back(Iterator first, Iterator last) {
913 typename std::iterator_traits<Iterator>::difference_type n = std::distance(first, last);
914 char* str = this->Alloc(n + 1);
915 if (!str)
return NULL;
916 std::copy(first, last, str);
918 char** rval = list_.push_back(str);
919 if (!rval) this->Dealloc(str);
924 bool StringList<AL>::pop_back() NLIB_NOEXCEPT {
925 if (list_.empty())
return false;
926 Dealloc(list_.back());
927 return list_.pop_back();
931 char** StringList<AL>::Replace(iterator it,
const char* str) {
934 dup = this->StrDup(str);
935 if (!dup)
return NULL;
959 template <
class T,
class Distance>
960 inline void advance(::nlib_ns::nlist::NlistIterator<T>& pos,
962 pos.Advance(static_cast<size_t>(n));
966 inline std::ptrdiff_t distance(const ::nlib_ns::nlist::NlistIterator<T>& first,
967 const ::nlib_ns::nlist::NlistIterator<T>& last) {
968 return first.Distance(last);
973 #ifndef NLIB_STD_SWAP_WORKAROUND 976 NLIB_DEFINE_STD_SWAP_T_BEGIN1(
std)
979 NLIB_DEFINE_STD_SWAP_T2(T, AL, NLIB_NS::Nlist)
980 NLIB_DEFINE_STD_SWAP_T1(AL, NLIB_NS::StringList)
982 #ifndef NLIB_STD_SWAP_WORKAROUND 985 NLIB_DEFINE_STD_SWAP_T_END1(
std)
988 #endif // INCLUDE_NN_NLIB_NLIST_H_ Nlist(const AL &al) noexcept
Specifies an allocator. Creates an empty container.
void swap(Nlist &rhs) noexcept
Swaps the container.
BaseType::const_pointer const_pointer
const T*.
reference back()
Returns a reference to the last element.
BaseType::pointer pointer
T*.
Substitute definitions for the C++11 standard header type_traits. These substitute definitions are us...
Nlist() noexcept
Instantiates the object with default parameters (default constructor). Creates an empty container...
BaseType::reference reference
T&.
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
Prohibits use of the copy constructor and assignment operator for the class specified by TypeName...
bool operator>=(const Nlist< T, AL1 > &lhs, const Nlist< T, AL2 > &rhs) noexcept
Compares two lists in dictionary order.
const_iterator begin() const noexcept
Returns the iterator pointing to the beginning of the container.
pointer EmplaceBack(const A1 &a1, const A2 &a2, const A3 &a3)
Adds elements in-place.
BaseType::size_type size_type
Unsigned integer type (size_t).
bool operator>(const Nlist< T, AL1 > &lhs, const Nlist< T, AL2 > &rhs) noexcept
Compares two lists in dictionary order.
iterator begin() noexcept
Returns the iterator pointing to the beginning of the container.
void shrink_to_fit() noexcept
Returns allocated memory, if possible.
allocator_type get_allocator() const noexcept
Gets the allocator.
const_reference back() const
The same as back.
const_iterator end() const noexcept
Returns the iterator pointing to the end of the container.
bool operator==(const HeapHash &rhs, const HeapHash &lhs)
Returns true if the two compared summaries are equal.
bool operator!=(const HeapHash &rhs, const HeapHash &lhs)
Returns true if the two compared summaries are not equal.
BaseType::const_iterator const_iterator
Read-only forward iterator.
Object created when MessagePack or JSON is read.
size_type capacity() const noexcept
Returns the number of allocated elements.
bool resize(size_type n) noexcept
Resizes the container.
pointer push_back()
Adds an element to the end and initializes it with the default constructor.
reference operator[](size_type idx)
Uses an index to reference an element.
pointer EmplaceBack(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4)
Adds elements in-place.
void clear() noexcept
Clears the container.
#define NLIB_CATCH(x)
Defines catch(x) if exceptions are enabled. If not, defines if (true).
#define NLIB_TRY
Defines try if exceptions are enabled. If not, defines if (true).
reference front()
Returns a reference to the first element.
BaseType::iterator iterator
Forward iterator.
BaseType::difference_type difference_type
Signed integer type (ptrdiff_t).
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
BaseType::value_type value_type
Element type T.
#define NLIB_CEXPR
Defines constexpr if it is available for use. If not, holds an empty string.
A file that contains the configuration information for each development environment.
TimeSpan operator*(int i, const TimeSpan &rhs) noexcept
Increases rhs by a factor of i.
pointer EmplaceBack(const A1 &a1)
Adds elements in-place.
bool reserve(size_type n) noexcept
Allocates memory for n number of elements.
void Clobber() noexcept
Returns the container empty without calling the element destructor and without releasing the memory f...
A container-like class similar to std::vector that can store objects that do not have copy constructo...
const_reference front() const
The same as front.
const_iterator cend() const noexcept
Returns the iterator pointing to the end of the container.
size_type size() const noexcept
Returns the number of stored elements.
#define NLIB_STATIC_ASSERT(exp)
Defines a static assertion. Uses static_assert if it is available for use.
bool empty() const noexcept
Checks whether the container is empty.
const_reference operator[](size_type idx) const
The same as operator[](size_t idx).
#define NLIB_ALIGNOF(tp)
Defines alignof(tp) or the equivalent.
pointer EmplaceBack(const A1 &a1, const A2 &a2)
Adds elements in-place.
pointer EmplaceBack(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5)
Adds elements in-place.
AL allocator_type
Allocator type AL.
BaseType::reference const_reference
const T&.
const_iterator cbegin() const noexcept
Returns the iterator pointing to the beginning of the container.
iterator end() noexcept
Returns the iterator pointing to the end of the container.
bool pop_back() noexcept
Deletes the last element.