16 #ifndef INCLUDE_NN_NLIB_NLIST_H_ 17 #define INCLUDE_NN_NLIB_NLIST_H_ 26 #include "nn/nlib/Swap.h" 31 template <
class T,
class AL>
49 return 8 * ((1 << level) - 1);
52 return 8 * (1 << level);
55 bool ConfirmBack() const NLIB_NOEXCEPT;
56 void ClearSimple() NLIB_NOEXCEPT {
65 mutable size_t curlevel_;
66 mutable size_t curidx_;
67 mutable Blk* firstblk_;
74 class NlistConstIterator;
79 class NlistBaseT :
public NlistBase {
82 typedef const T& const_reference;
83 typedef NlistIterator<T> iterator;
84 typedef NlistConstIterator<T> const_iterator;
85 typedef size_t size_type;
88 typedef const T* const_pointer;
89 typedef ptrdiff_t difference_type;
94 return reinterpret_cast<T*
>(blk->item);
97 return reinterpret_cast<const T*
>(blk->item);
101 const Blk* p = this->AtSub(n, &base);
102 return p ?
const_cast<T*
>(&(GetItem(p)[n - base])) : NULL;
104 iterator Begin()
NLIB_NOEXCEPT {
return iterator(
this, TrueType()); }
105 iterator End()
NLIB_NOEXCEPT {
return iterator(
this, FalseType()); }
107 return const_iterator(
this, TrueType());
110 return const_iterator(
this, FalseType());
115 friend class NlistConstIterator<T>;
116 friend class NlistIterator<T>;
120 class NlistConstIterator
121 :
public std::iterator<std::forward_iterator_tag, T> {
123 typedef NlistBaseT<T> ContainerType;
124 typedef typename ContainerType::Blk Blk;
127 typedef typename std::iterator<std::forward_iterator_tag, T> BaseType;
128 typedef typename BaseType::iterator_category iterator_category;
129 typedef typename BaseType::value_type value_type;
130 typedef typename BaseType::difference_type difference_type;
131 typedef typename BaseType::pointer pointer;
132 typedef typename BaseType::reference reference;
141 NlistConstIterator(
const ContainerType* p, TrueType)
NLIB_NOEXCEPT {
142 ContainerType* rhs =
const_cast<ContainerType*
>(p);
144 blk_ = rhs->firstblk_;
145 elemptr_ = GetItem(blk_);
146 blkend_ = elemptr_ + 8;
148 NlistConstIterator(
const ContainerType* p, FalseType)
NLIB_NOEXCEPT {
149 ContainerType* rhs =
const_cast<ContainerType*
>(p);
150 idx_ = rhs->BlkBaseIdx(rhs->curlevel_) + rhs->curidx_;
152 elemptr_ = &(GetItem(blk_)[rhs->curidx_]);
153 blkend_ = GetItem(blk_) + rhs->BlkSize(rhs->curlevel_);
154 if (elemptr_ == blkend_) this->Normalize();
159 const T* operator->() const
NLIB_NOEXCEPT {
return elemptr_; }
161 NLIB_ASSERT(elemptr_ != blkend_);
163 if (++elemptr_ == blkend_) this->Normalize();
167 NlistConstIterator rval(*
this);
172 return idx_ == rhs.idx_ && elemptr_ == rhs.elemptr_;
178 difference_type Distance(NlistConstIterator to)
const NLIB_NOEXCEPT {
179 return to.idx_ - idx_;
183 static T* GetItem(Blk* blk) NLIB_NOEXCEPT {
184 return reinterpret_cast<T*
>(blk->item);
186 static const T* GetItem(
const Blk* blk) NLIB_NOEXCEPT {
187 return reinterpret_cast<const T*
>(blk->item);
189 bool Normalize() NLIB_NOEXCEPT;
196 friend class NlistBaseT<T>;
200 bool NlistConstIterator<T>::Normalize() NLIB_NOEXCEPT {
201 if (blk_ && blk_->next) {
202 Blk* next = blk_->next;
203 size_t next_size = 2 *
static_cast<size_t>(blkend_ - GetItem(blk_));
204 T* next_elemptr = GetItem(next);
205 T* next_end = next_elemptr + next_size;
207 elemptr_ = next_elemptr;
215 void NlistConstIterator<T>::Advance(difference_type n) NLIB_NOEXCEPT {
216 while (elemptr_ + n >= blkend_) {
217 n -= blkend_ - elemptr_;
218 idx_ += blkend_ - elemptr_;
220 if (!this->Normalize())
return;
227 class NlistIterator :
public NlistConstIterator<T> {
229 typedef NlistBaseT<T> ContainerType;
230 typedef typename ContainerType::Blk Blk;
231 typedef NlistConstIterator<T> MyBase;
234 typedef typename NlistConstIterator<T>::BaseType BaseType;
235 typedef typename BaseType::iterator_category iterator_category;
236 typedef typename BaseType::value_type value_type;
237 typedef typename BaseType::difference_type difference_type;
238 typedef typename BaseType::pointer pointer;
239 typedef typename BaseType::reference reference;
242 NLIB_CEXPR NlistIterator() NLIB_NOEXCEPT : MyBase() {}
245 NlistIterator(
const ContainerType* p, TrueType)
NLIB_NOEXCEPT : MyBase(p, TrueType()) {}
246 NlistIterator(
const ContainerType* p, FalseType)
NLIB_NOEXCEPT : MyBase(p, FalseType()) {}
250 const MyBase* tmp =
static_cast<const MyBase*
>(
this);
251 return const_cast<T&
>(**tmp);
253 T* operator->() const NLIB_NOEXCEPT {
254 const MyBase* tmp =
static_cast<const MyBase*
>(
this);
255 return const_cast<T*
>(tmp->operator->());
257 NlistIterator& operator++() NLIB_NOEXCEPT {
258 MyBase* tmp =
static_cast<MyBase*
>(
this);
262 NlistIterator operator++(
int) NLIB_NOEXCEPT {
263 NlistIterator rval(*
this);
267 bool operator==(
const NlistIterator& rhs)
const NLIB_NOEXCEPT {
268 const MyBase* tmp =
static_cast<const MyBase*
>(
this);
269 const MyBase* tmp2 =
static_cast<const MyBase*
>(&rhs);
270 return *tmp == *tmp2;
272 bool operator!=(
const NlistIterator& rhs)
const NLIB_NOEXCEPT {
275 difference_type Distance(NlistIterator to)
const NLIB_NOEXCEPT {
276 const MyBase* tmp =
static_cast<const MyBase*
>(
this);
277 const MyBase* tmp2 =
static_cast<const MyBase*
>(&to);
278 return tmp->Distance(*tmp2);
282 friend class NlistBaseT<T>;
285 template<
bool is_empty,
class AL>
288 NlistAlloc() NLIB_NOEXCEPT : alloc_(AL()) {}
289 explicit NlistAlloc(
const AL& al)
NLIB_NOEXCEPT : alloc_(al) {}
292 AL& _GetNlistAlloc() const NLIB_NOEXCEPT {
293 return const_cast<AL&
>(alloc_);
295 void _SwapNlistAlloc(NlistAlloc& rhs) NLIB_NOEXCEPT {
297 swap(alloc_, rhs.alloc_);
305 class NlistAlloc <true, AL> {
307 NlistAlloc() NLIB_NOEXCEPT {}
308 explicit NlistAlloc(
const AL& al) NLIB_NOEXCEPT { NLIB_UNUSED(al); }
311 AL _GetNlistAlloc() const NLIB_NOEXCEPT {
return AL(); }
312 void _SwapNlistAlloc(NlistAlloc& rhs) NLIB_NOEXCEPT {
319 template <
class T,
class AL = std::allocator<
char> >
320 class Nlist :
public nlist::NlistBaseT<T>,
321 public nlist::NlistAlloc<IsEmpty<AL>::value, AL> {
346 typedef typename nlist::NlistBaseT<T> BaseType;
347 typedef typename nlist::NlistAlloc<IsEmpty<AL>::value, AL> AllocType;
348 using BaseType::curblk_;
349 using BaseType::curidx_;
350 using BaseType::curlevel_;
351 using BaseType::firstblk_;
352 using BaseType::ConfirmBack;
353 using BaseType::ClearSimple;
354 using BaseType::BlkBaseIdx;
355 using BaseType::BlkSize;
356 using BaseType::GetItem;
357 using BaseType::Begin;
359 typedef typename BaseType::Blk Blk;
374 Nlist() NLIB_NOEXCEPT : AllocType(AL()) {}
377 NLIB_MOVE_MEMBER_HELPER_2(
Nlist, BaseType, AllocType)
378 size_type size() const NLIB_NOEXCEPT {
379 return BlkBaseIdx(curlevel_) + curidx_;
383 return (NULL != this->LastBlock(&lv)) ? BlkBaseIdx(lv + 1) : 0;
385 bool empty() const NLIB_NOEXCEPT {
return curlevel_ == 0 && curidx_ == 0; }
387 return Resize(n,
typename IsTriviallyDefaultConstructible<T>::type());
391 void* p = this->PushBack();
393 pointer ptr = MyCtor(p,
typename IsTriviallyDefaultConstructible<T>::type());
397 #ifdef NLIB_CXX11_RVALUE_REFERENCES 398 pointer push_back(T&& rhs) NLIB_NOEXCEPT {
399 #if defined(NLIB_HAS_NATIVE_TYPETRAITS) && !defined(NLIB_HAS_TR1_TYPETRAITS) 402 void* p = this->PushBack();
404 pointer ptr =
new (p) T(std::forward<T>(rhs));
409 pointer push_back(
const T& rhs) {
410 void* p = this->PushBack();
412 pointer ptr =
new (p) T(rhs);
417 return this->pop_back_(
typename IsTriviallyDestructible<T>::type());
422 swap(curblk_, rhs.curblk_);
423 swap(curlevel_, rhs.curlevel_);
424 swap(curidx_, rhs.curidx_);
425 swap(firstblk_, rhs.firstblk_);
426 AllocType::_SwapNlistAlloc(rhs);
429 Clear(
typename IsTriviallyDestructible<T>::type());
432 return AllocType::_GetNlistAlloc();
436 if (curidx_ == 0) ConfirmBack();
437 return GetItem(curblk_)[curidx_ - 1];
440 if (curidx_ == 0) ConfirmBack();
441 return GetItem(curblk_)[curidx_ - 1];
443 const_reference
front()
const {
return GetItem(firstblk_)[0]; }
444 reference
front() {
return GetItem(firstblk_)[0]; }
446 NLIB_ASSERT(idx < this->size());
447 return *this->At(idx);
450 NLIB_ASSERT(idx < this->size());
451 return *this->At(idx);
455 if (!firstblk_ && !ConfirmFirstBlk())
return iterator();
458 const_iterator
begin() const NLIB_NOEXCEPT {
459 if (!firstblk_ && !ConfirmFirstBlk())
return const_iterator();
462 const_iterator
cbegin() const NLIB_NOEXCEPT {
463 if (!firstblk_ && !ConfirmFirstBlk())
return const_iterator();
467 iterator
end() NLIB_NOEXCEPT {
468 if (!firstblk_ && !ConfirmFirstBlk())
return iterator();
471 const_iterator
end() const NLIB_NOEXCEPT {
472 if (!firstblk_ && !ConfirmFirstBlk())
return const_iterator();
475 const_iterator
cend() const NLIB_NOEXCEPT {
476 if (!firstblk_ && !ConfirmFirstBlk())
return const_iterator();
481 if (!curblk_)
return;
482 Blk* p = curblk_->next;
483 curblk_->next = NULL;
484 DeallocBlkList(p, static_cast<int>(curlevel_ + 1));
486 #if defined(NLIB_CXX11_RVALUE_REFERENCES) && defined(NLIB_CXX11_VARIADIC_TEMPLATES) 487 template<
class... Args>
488 pointer EmplaceBack(Args&&... args) {
489 void* p = this->PushBack();
491 pointer ptr =
new (p) T(std::forward<Args>(args)...);
498 void* p = this->PushBack();
500 pointer ptr =
new (p) T(
const_cast<typename RemoveConst<A1>::type&
>(a1));
504 template <
class A1,
class A2>
506 void* p = this->PushBack();
508 pointer ptr =
new (p) T(
const_cast<typename RemoveConst<A1>::type&
>(a1),
509 const_cast<typename RemoveConst<A2>::type&
>(a2));
513 template <
class A1,
class A2,
class A3>
515 void* p = this->PushBack();
517 pointer ptr =
new (p) T(
const_cast<typename RemoveConst<A1>::type&
>(a1),
518 const_cast<typename RemoveConst<A2>::type&
>(a2),
519 const_cast<typename RemoveConst<A3>::type&
>(a3));
523 template <
class A1,
class A2,
class A3,
class A4>
524 pointer
EmplaceBack(
const A1& a1,
const A2& a2,
const A3& a3,
const A4& a4) {
525 void* p = this->PushBack();
527 pointer ptr =
new (p) T(
const_cast<typename RemoveConst<A1>::type&
>(a1),
528 const_cast<typename RemoveConst<A2>::type&
>(a2),
529 const_cast<typename RemoveConst<A3>::type&
>(a3),
530 const_cast<typename RemoveConst<A4>::type&
>(a4));
534 template <
class A1,
class A2,
class A3,
class A4,
class A5>
536 EmplaceBack(
const A1& a1,
const A2& a2,
const A3& a3,
const A4& a4,
const A5& a5) {
537 void* p = this->PushBack();
539 pointer ptr =
new (p) T(
const_cast<typename RemoveConst<A1>::type&
>(a1),
540 const_cast<typename RemoveConst<A2>::type&
>(a2),
541 const_cast<typename RemoveConst<A3>::type&
>(a3),
542 const_cast<typename RemoveConst<A4>::type&
>(a4),
543 const_cast<typename RemoveConst<A5>::type&
>(a5));
559 void DestroyBlk(Blk*,
size_t, TrueType)
const NLIB_NOEXCEPT {}
560 void DestroyBlk(Blk* p,
size_t n, FalseType)
const NLIB_NOEXCEPT;
561 void DestroyBlk(Blk* p,
size_t n)
const NLIB_NOEXCEPT {
562 DestroyBlk(p, n,
typename IsTriviallyDestructible<T>::type());
567 void Clear(TrueType) NLIB_NOEXCEPT { ClearSimple(); }
570 T* MyCtor(
void* p, TrueType) NLIB_NOEXCEPT {
571 return reinterpret_cast<T*
>(p);
573 T* MyCtor(
void* p, FalseType) {
577 bool pop_back_(FalseType) NLIB_NOEXCEPT {
579 if (!ConfirmBack())
return false;
581 reference item = GetItem(curblk_)[--curidx_];
586 bool pop_back_(TrueType) NLIB_NOEXCEPT {
588 if (!ConfirmBack())
return false;
598 template <
class T,
class AL>
601 this->DeallocBlkList(firstblk_, 0);
606 template <
class T,
class AL>
607 class ResizeRewinder {
610 void PushBack(
size_t n) {
611 for (; count_ < n; ++count_) {
616 ~ResizeRewinder() NLIB_NOEXCEPT {
617 for (; count_ > 0; --count_) {
630 template <
class T,
class AL>
633 size_t sz = this->size();
634 if (n == sz)
return true;
636 for (
size_t i = sz; i > n; --i) {
640 if (!this->reserve(n))
return false;
641 nlist::ResizeRewinder<T, AL> rewinder(*
this);
642 rewinder.PushBack(n);
647 template <
class T,
class AL>
649 size_type sz = this->size();
650 if (n == sz)
return true;
652 for (size_type i = sz; i > n; --i) {
656 if (!this->reserve(n))
return false;
660 size_t lower = this->BlkBaseIdx(curlevel_);
661 size_t upper = this->BlkBaseIdx(curlevel_ + 1);
664 curblk_ = curblk_->next;
666 upper = this->BlkBaseIdx(curlevel_ + 1);
668 curidx_ =
static_cast<size_t>(n - lower);
673 template <
class T,
class AL>
675 if (n == 0 || n <= BlkBaseIdx(curlevel_ + 1))
return true;
676 if (!firstblk_ && !this->ConfirmFirstBlk())
return false;
678 Blk* blk = this->LastBlock(&lv);
680 if (n <= BlkBaseIdx(lv + 1))
return true;
682 Blk* p = this->AllocBlk(BlkSize(lv));
683 if (!p)
return false;
689 template <
class T,
class AL>
694 size_t sz =
sizeof(Blk) + n *
sizeof(T);
697 pp = AllocType::_GetNlistAlloc().allocate(sz);
699 #ifdef NLIB_EXCEPTION_ENABLED 700 NLIB_CATCH(
const std::bad_alloc&) {
return NULL; }
702 if (!pp)
return NULL;
703 Blk* p =
reinterpret_cast<Blk*
>(pp);
705 p->item =
reinterpret_cast<T*
>(p + 1);
709 template <
class T,
class AL>
712 size_t n = BlkSize(lv);
717 AllocType::_GetNlistAlloc().deallocate(reinterpret_cast<char*>(pp),
718 sizeof(Blk) + n *
sizeof(T));
723 template <
class T,
class AL>
728 T* base =
reinterpret_cast<T*
>(p->item);
730 for (
size_t i = 0; i < n; ++i) {
735 template <
class T,
class AL>
737 Blk* p = AllocBlk(BlkSize(0));
738 if (!p)
return false;
746 template <
class T,
class AL>
748 if (!firstblk_ && !ConfirmFirstBlk())
return NULL;
749 if (curidx_ == BlkSize(curlevel_)) {
750 if (!curblk_->next) {
751 Blk* p = AllocBlk(BlkSize(curlevel_ + 1));
756 curblk_ = curblk_->next;
763 T& item = GetItem(curblk_)[curidx_];
767 template <
class T,
class AL>
772 while (p != curblk_) {
773 size_t cnt = BlkSize(lv);
779 DestroyBlk(p, curidx_);
784 template <
class T,
class AL1,
class AL2>
787 return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin());
790 template <
class T,
class AL1,
class AL2>
793 return !(lhs == rhs);
796 template <
class T,
class AL1,
class AL2>
797 inline bool operator<(const Nlist<T, AL1>& lhs,
799 return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
802 template <
class T,
class AL1,
class AL2>
808 template <
class T,
class AL1,
class AL2>
809 inline bool operator<=(const Nlist<T, AL1>& lhs,
811 return (!(rhs < lhs));
814 template <
class T,
class AL1,
class AL2>
817 return (!(lhs < rhs));
820 template <
class AL = std::allocator<
char> >
825 typedef AL allocator_type;
826 typedef typename ContainerType::iterator iterator;
827 typedef typename ContainerType::const_iterator const_iterator;
831 explicit StringList(
const AL& al) : list_(al) {}
833 size_t size()
const NLIB_NOEXCEPT {
return list_.size(); }
834 size_t capacity()
const NLIB_NOEXCEPT {
return list_.capacity(); }
835 bool empty()
const NLIB_NOEXCEPT {
return list_.empty(); }
836 bool reserve(
size_t n) {
return list_.reserve(n); }
837 bool resize(
size_t n) {
return list_.resize(n); }
839 char** push_back(
const char* str);
840 template <
class Iterator>
841 char** push_back(Iterator first, Iterator last);
844 void swap(StringList& rhs) NLIB_NOEXCEPT { list_.swap(rhs.list_); }
845 void clear() NLIB_NOEXCEPT { list_.clear(); }
846 allocator_type get_allocator()
const {
return list_.get_allocator(); }
848 const char* back()
const {
return list_.back(); }
849 char* back() {
return list_.back(); }
850 const char* front()
const {
return list_.front(); }
851 char* front() {
return list_.front(); }
852 const char* operator[](
size_t idx)
const {
return list_[idx]; }
853 char* operator[](
size_t idx) {
return list_[idx]; }
854 iterator begin() NLIB_NOEXCEPT {
return list_.begin(); }
855 const_iterator begin()
const NLIB_NOEXCEPT {
return list_.begin(); }
856 const_iterator cbegin() NLIB_NOEXCEPT {
return list_.cbegin(); }
858 iterator end() NLIB_NOEXCEPT {
return list_.end(); }
859 const_iterator end()
const NLIB_NOEXCEPT {
return list_.end(); }
860 const_iterator cend() NLIB_NOEXCEPT {
return list_.cend(); }
862 void shrink_to_fit() { list_.shrink_to_fit(); }
863 void Clobber() NLIB_NOEXCEPT { list_.clobber(); }
865 char** Replace(iterator it,
const char* str);
866 char** Replace(
size_t idx,
const char* str) {
867 if (idx >= list_.size())
return NULL;
868 iterator it = list_.begin();
870 return this->Replace(it, str);
874 void Dealloc(
const char* ptr)
const {
877 this->get_allocator().deallocate(const_cast<char*>(ptr), 0);
880 char* StrDup(
const char* ptr)
const;
881 char* Alloc(
size_t nbytes)
const {
882 return this->get_allocator().allocate(nbytes);
891 char* StringList<AL>::StrDup(
const char* ptr)
const {
893 void* p = this->Alloc(nbytes);
896 return reinterpret_cast<char*
>(p);
900 StringList<AL>::~StringList() NLIB_NOEXCEPT {
901 const_iterator it = this->cbegin();
902 const_iterator it_end = this->cend();
903 while (it != it_end) {
910 char** StringList<AL>::push_back(
const char* str) {
913 dup = this->StrDup(str);
914 if (!dup)
return NULL;
918 char** ptr_str = list_.push_back(dup);
919 if (!ptr_str) this->Dealloc(dup);
924 template <
class Iterator>
925 char** StringList<AL>::push_back(Iterator first, Iterator last) {
926 typename std::iterator_traits<Iterator>::difference_type n = std::distance(first, last);
927 char* str = this->Alloc(n + 1);
928 if (!str)
return NULL;
929 std::copy(first, last, str);
931 char** rval = list_.push_back(str);
932 if (!rval) this->Dealloc(str);
937 bool StringList<AL>::pop_back() NLIB_NOEXCEPT {
938 if (list_.empty())
return false;
939 Dealloc(list_.back());
940 return list_.pop_back();
944 char** StringList<AL>::Replace(iterator it,
const char* str) {
947 dup = this->StrDup(str);
948 if (!dup)
return NULL;
972 template <
class T,
class Distance>
973 inline void advance(::nlib_ns::nlist::NlistIterator<T>& pos,
975 pos.Advance(static_cast<size_t>(n));
979 inline std::ptrdiff_t distance(const ::nlib_ns::nlist::NlistIterator<T>& first,
980 const ::nlib_ns::nlist::NlistIterator<T>& last) {
981 return first.Distance(last);
986 #ifndef NLIB_STD_SWAP_WORKAROUND 989 NLIB_DEFINE_STD_SWAP_T_BEGIN1(
std)
992 NLIB_DEFINE_STD_SWAP_T2(T, AL, NLIB_NS::Nlist)
993 NLIB_DEFINE_STD_SWAP_T1(AL, NLIB_NS::StringList)
995 #ifndef NLIB_STD_SWAP_WORKAROUND 998 NLIB_DEFINE_STD_SWAP_T_END1(
std)
1001 #endif // INCLUDE_NN_NLIB_NLIST_H_ Nlist(const AL &al) noexcept
アロケータを指定します。空のコンテナを作成します。
void swap(Nlist &rhs) noexcept
コンテナをスワップします。
BaseType::const_pointer const_pointer
const T*
reference back()
末尾の要素の参照を返します。
BaseType::pointer pointer
T*
C++11の標準ヘッダとなるtype_traitsの代用定義です。 コンパイラや標準ライブラリによってサポートされてい...
Nlist() noexcept
デフォルトコンストラクタです。空のコンテナを作成します。
BaseType::reference reference
T&
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
TypeName で指定されたクラスのコピーコンストラクタと代入演算子を禁止します。
bool operator>=(const Nlist< T, AL1 > &lhs, const Nlist< T, AL2 > &rhs) noexcept
2つのリストを辞書順で比較します。
const_iterator begin() const noexcept
コンテナの先頭を指す反復子を返します。
pointer EmplaceBack(const A1 &a1, const A2 &a2, const A3 &a3)
インプレイスで要素を追加します。
BaseType::size_type size_type
符号なし整数型(size_t)
bool operator>(const Nlist< T, AL1 > &lhs, const Nlist< T, AL2 > &rhs) noexcept
2つのリストを辞書順で比較します。
iterator begin() noexcept
コンテナの先頭を指す反復子を返します。
void shrink_to_fit() noexcept
可能ならばアロケートされたメモリを返却します。
allocator_type get_allocator() const noexcept
アロケータを取得します。
const_reference back() const
back()と同様です。
const_iterator end() const noexcept
コンテナの末尾を指す反復子を返します。
bool operator==(const HeapHash &rhs, const HeapHash &lhs)
2つのサマリを比較して等価ならば、trueを返します。
bool operator!=(const HeapHash &rhs, const HeapHash &lhs)
2つのサマリを比較して等価でなければ、trueを返します。
BaseType::const_iterator const_iterator
読み取り専用フォワードイテレータ
MessagePack又はJSONを読み込むことで作成されるオブジェクトです。
size_type capacity() const noexcept
アロケート済みの要素の個数を返します。
bool resize(size_type n) noexcept
コンテナをリサイズします。
pointer push_back()
末尾に要素を追加してデフォルトコンストラクタで初期化します。
reference operator[](size_type idx)
インデックスで要素を参照します。
pointer EmplaceBack(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4)
インプレイスで要素を追加します。
void clear() noexcept
コンテナをクリアします。
#define NLIB_CATCH(x)
例外が有効なときはcatch(x), そうでなければif (true)が定義されます。
#define NLIB_TRY
例外が有効なときはtry, そうでなければif (true)が定義されます。
reference front()
先頭の要素の参照を返します。
BaseType::iterator iterator
フォワードイテレータ
BaseType::difference_type difference_type
符号つき整数型(ptrdiff_t)
#define NLIB_NOEXCEPT
環境に合わせてnoexcept 又は同等の定義がされます。
BaseType::value_type value_type
要素型 T
#define NLIB_CEXPR
利用可能であればconstexprが定義されます。そうでない場合は空文字列です。
TimeSpan operator*(int i, const TimeSpan &rhs) noexcept
rhs を i 倍します。
pointer EmplaceBack(const A1 &a1)
インプレイスで要素を追加します。
bool reserve(size_type n) noexcept
n 個の要素のためのメモリをアロケート済みにします。
void Clobber() noexcept
要素のデストラクタを呼んだりコンテナのメモリを解放することなく、コンテナを空に戻す。 ...
std::vectorに似た、コピーコンストラクタを持たないオブジェクトを格納可能なコンテナ類似クラスです。 ...
const_reference front() const
front()と同様です。
const_iterator cend() const noexcept
コンテナの末尾を指す反復子を返します。
size_type size() const noexcept
格納されている要素の個数を返します。
#define NLIB_STATIC_ASSERT(exp)
静的アサートが定義されます。利用可能であればstatic_assertを利用します。
bool empty() const noexcept
コンテナが空かどうかを調べます。
const_reference operator[](size_type idx) const
operator[](size_t idx) と同様です。
#define NLIB_ALIGNOF(tp)
alignof(tp)又は同等の定義がされます。
pointer EmplaceBack(const A1 &a1, const A2 &a2)
インプレイスで要素を追加します。
pointer EmplaceBack(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5)
インプレイスで要素を追加します。
AL allocator_type
アロケータの型 AL
BaseType::reference const_reference
const T&
const_iterator cbegin() const noexcept
コンテナの先頭を指す反復子を返します。
iterator end() noexcept
コンテナの末尾を指す反復子を返します。
bool pop_back() noexcept
末尾の要素を削除します。