From b762a2e1b016fc1c08bc995c574e29533fc2e339 Mon Sep 17 00:00:00 2001 From: cxl Date: Mon, 10 Feb 2014 12:55:28 +0000 Subject: [PATCH] Core: Index, VectorMap, ArrayMap now have HasUnlinked method git-svn-id: svn://ultimatepp.org/upp/trunk@6895 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Index.h | 2 ++ uppsrc/Core/Map.h | 1 + uppsrc/Core/src.tpp/AIndex$en-us.tpp | 5 +++++ uppsrc/Core/src.tpp/AMap$en-us.tpp | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/uppsrc/Core/Index.h b/uppsrc/Core/Index.h index 69c1a7fbf..0550cfc7a 100644 --- a/uppsrc/Core/Index.h +++ b/uppsrc/Core/Index.h @@ -41,6 +41,7 @@ public: bool IsUnlinked(int i) const { return hash[i] & UNSIGNED_HIBIT; } void Unlink(int i); Vector GetUnlinked() const; + bool HasUnlinked() const { return unlinked >= 0; } void Remove(int i); void Remove(int i, int count); @@ -142,6 +143,7 @@ public: bool IsUnlinked(int i) const { return hash.IsUnlinked(i); } Vector GetUnlinked() const { return hash.GetUnlinked(); } void Sweep(); + bool HasUnlinked() const { return hash.HasUnlinked(); } T& Insert(int i, const T& k, unsigned h); T& Insert(int i, const T& k); diff --git a/uppsrc/Core/Map.h b/uppsrc/Core/Map.h index cced1f6fb..c1caa297f 100644 --- a/uppsrc/Core/Map.h +++ b/uppsrc/Core/Map.h @@ -52,6 +52,7 @@ public: int UnlinkKey(const K& k) { return key.UnlinkKey(k); } bool IsUnlinked(int i) const { return key.IsUnlinked(i); } void Sweep(); + bool HasUnlinked() const { return key.HasUnlinked(); } T& Insert(int i, const K& k) { key.Insert(i, k); return value.Insert(i); } T& Insert(int i, const K& k, const T& x) { key.Insert(i, k); return value.Insert(i, x); } diff --git a/uppsrc/Core/src.tpp/AIndex$en-us.tpp b/uppsrc/Core/src.tpp/AIndex$en-us.tpp index 3125381f4..44cc1005a 100644 --- a/uppsrc/Core/src.tpp/AIndex$en-us.tpp +++ b/uppsrc/Core/src.tpp/AIndex$en-us.tpp @@ -357,6 +357,11 @@ operation depends on the number of elements in AIndex, not on the number of unlinked elements. Also restores multi`-key ordering.&] [s3;%- &] [s4;%- &] +[s5;:AIndex`:`:HasUnlinked`(`)const:%- [@(0.0.255) bool]_[* HasUnlinked]()_[@(0.0.255) cons +t]&] +[s2; Returns true of AIndex has any unlinked elements.&] +[s3;%- &] +[s4;%- &] [s5;:AIndex`:`:Insert`(int`,const T`&`,unsigned`):%- [*@4 T][@(0.0.255) `&]_[* Insert]([@(0.0.255) i nt]_[*@3 i], [@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 k], [@(0.0.255) unsigned]_[*@3 h])&] [s2; Inserts an element with value [%-*@3 k] at the specified position diff --git a/uppsrc/Core/src.tpp/AMap$en-us.tpp b/uppsrc/Core/src.tpp/AMap$en-us.tpp index a9d9afe55..b614edbcd 100644 --- a/uppsrc/Core/src.tpp/AMap$en-us.tpp +++ b/uppsrc/Core/src.tpp/AMap$en-us.tpp @@ -532,6 +532,10 @@ stay in AIndex but are ignored by any Find operations.&] [s2; Removes all unlinked elements from the container.&] [s3;%- &] [s4;%- &] +[s5;:AMap`:`:HasUnlinked`(`)const:%- [@(0.0.255) bool]_[* HasUnlinked]()_[@(0.0.255) const]&] +[s2; Returns true if AMap has any unlinked elements.&] +[s3;%- &] +[s4;%- &] [s5;:AMap`:`:Insert`(int`,const K`&`):%- [*@4 T][@(0.0.255) `&]_[* Insert]([@(0.0.255) int]_[*@3 i ], [@(0.0.255) const]_[*@4 K][@(0.0.255) `&]_[*@3 k])&] [s2; Inserts an element with the specified key and default constructed