From c6255d91904a72d2a993bc3e3de6097d7cfec91e Mon Sep 17 00:00:00 2001 From: cxl Date: Wed, 27 Oct 2010 08:08:50 +0000 Subject: [PATCH] Core: Index, Map: GetHash git-svn-id: svn://ultimatepp.org/upp/trunk@2824 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Index.h | 2 ++ uppsrc/Core/Map.h | 2 ++ uppsrc/Core/src.tpp/AIndex$en-us.tpp | 6 ++++++ uppsrc/Core/src.tpp/AMap$en-us.tpp | 6 ++++++ 4 files changed, 16 insertions(+) diff --git a/uppsrc/Core/Index.h b/uppsrc/Core/Index.h index 3bf6fd30a..5fe4f270e 100644 --- a/uppsrc/Core/Index.h +++ b/uppsrc/Core/Index.h @@ -127,6 +127,8 @@ public: const T& operator[](int i) const { return key[i]; } int GetCount() const { return key.GetCount(); } bool IsEmpty() const { return key.IsEmpty(); } + + unsigned GetHash(int i) const { return hash[i]; } void Clear() { hash.Clear(); key.Clear(); } diff --git a/uppsrc/Core/Map.h b/uppsrc/Core/Map.h index ffce6bb2c..df52b993c 100644 --- a/uppsrc/Core/Map.h +++ b/uppsrc/Core/Map.h @@ -75,6 +75,8 @@ public: void Reserve(int xtra) { value.Reserve(xtra); key.Reserve(xtra); } int GetAlloc() const { return value.GetAlloc(); } + unsigned GetHash(int i) const { return key.GetHash(i); } + void Drop(int n = 1) { key.Drop(n); value.Drop(n); } T& Top() { return value.Top(); } const T& Top() const { return value.Top(); } diff --git a/uppsrc/Core/src.tpp/AIndex$en-us.tpp b/uppsrc/Core/src.tpp/AIndex$en-us.tpp index c665dd801..4c33265b8 100644 --- a/uppsrc/Core/src.tpp/AIndex$en-us.tpp +++ b/uppsrc/Core/src.tpp/AIndex$en-us.tpp @@ -308,6 +308,12 @@ tor`[`]]([@(0.0.255) int]_[*@3 i])_[@(0.0.255) const]&] [s2; Tests whether AIndex is empty. Same as GetCount() `=`= 0.&] [s3;%- &] [s4;%- &] +[s5;:AIndex`:`:GetHash`(int`)const:%- [@(0.0.255) unsigned]_[* GetHash]([@(0.0.255) int]_[*@3 i +])_[@(0.0.255) const]&] +[s2; Returns a hash of element [%-*@3 i]. This is perhaps only useful +when making the exact copy of Index, e.g. in the persistent storage.&] +[s3; &] +[s4;%- &] [s5;:AIndex`:`:Clear`(`):%- [@(0.0.255) void]_[* Clear]()&] [s2; Removes all elements from AIndex.&] [s3;%- &] diff --git a/uppsrc/Core/src.tpp/AMap$en-us.tpp b/uppsrc/Core/src.tpp/AMap$en-us.tpp index 8961c3979..113d56d62 100644 --- a/uppsrc/Core/src.tpp/AMap$en-us.tpp +++ b/uppsrc/Core/src.tpp/AMap$en-us.tpp @@ -642,6 +642,12 @@ current capacity, capacity is increased to the required value.&] [s7; [*/ Return value]-|Capacity of Array.&] [s3;%- &] [s4;%- &] +[s5;:AMap`:`:GetHash`(int`)const:%- [@(0.0.255) unsigned]_[* GetHash]([@(0.0.255) int]_[*@3 i +])_[@(0.0.255) const]&] +[s2; Returns a hash of element [%-*@3 i]. This is perhaps only useful +when making the exact copy of AMap, e.g. in the persistent storage.&] +[s3; &] +[s4;%- &] [s5;:AMap`:`:Drop`(int`):%- [@(0.0.255) void]_[* Drop]([@(0.0.255) int]_[*@3 n]_`=_[@3 1])&] [s2; Drops the specified number of elements at the end of the AMap.&] [s7; [*C@3 n]-|Number of elements.&]