Core: Fixed SortedVectorMap::Add cloning issue, added r-value variant

git-svn-id: svn://ultimatepp.org/upp/trunk@11886 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2018-04-13 08:14:17 +00:00
parent 707c0584bc
commit 39737ced99
3 changed files with 9 additions and 3 deletions

View file

@ -646,7 +646,8 @@ class SortedVectorMap : public SortedAMap<K, T, Less, Slaved_InVector__<T> >,
public:
T& Add(const K& k) { B::key.Add(k); return *B::value.res; }
T& Add(const K& k, const T& x) { B::key.Add(k); *B::value.res = x; return *B::value.res; }
T& Add(const K& k, const T& x) { B::key.Add(k); *B::value.res = clone(x); return *B::value.res; }
T& Add(const K& k, T&& x) { B::key.Add(k); *B::value.res = pick(x); return *B::value.res; }
int FindAdd(const K& k) { return B::key.FindAdd(k); }
int FindAdd(const K& k, const T& init);
@ -724,6 +725,7 @@ class SortedArrayMap : public MoveableAndDeepCopyOption<SortedArrayMap<K, T, Les
public:
T& Add(const K& k, const T& x) { B::value.res = new T(clone(x)); B::key.Add(k); return *(T*)B::value.res; }
T& Add(const K& k, T&& x) { B::value.res = new T(pick(x)); B::key.Add(k); return *(T*)B::value.res; }
T& Add(const K& k) { B::value.res = NULL; B::key.Add(k); return *(T*)B::value.res; }
T& Add(const K& k, T *newt) { B::value.res = newt; B::key.Add(k); return *newt; }
template <class TT, class... Args>

View file

@ -1,5 +1,4 @@
topic "SortedArrayMap";
[2 $$0,0#00000000000000000000000000000000:Default]
[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class]
[l288;2 $$2,2#27521748481378242620020725143825:desc]
[0 $$3,0#96390100711032703541132217272105:end]
@ -9,6 +8,7 @@ topic "SortedArrayMap";
[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param]
[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam]
[b42;2 $$9,9#13035079074754324216151401829390:normal]
[2 $$0,0#00000000000000000000000000000000:Default]
[{_}%EN-US
[ {{10000@(113.42.0) [s0; [*@7;4 SortedArrayMap]]}}&]
[s0;i448;a25;kKO9;@(0.0.255)%- &]
@ -30,6 +30,8 @@ be derived from [%-*@4 T].&]
[s3;%- &]
[s5;:SortedArrayMap`:`:Add`(const K`&`,const T`&`):%- [*@4 T][@(0.0.255) `&]_[* Add]([@(0.0.255) c
onst]_[*@4 K][@(0.0.255) `&]_[*@3 k], [@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 x])&]
[s5;:Upp`:`:SortedArrayMap`:`:Add`(const K`&`,T`&`&`):%- [*@4 T][@(0.0.255) `&]_[* Add]([@(0.0.255) c
onst]_[*@4 K][@(0.0.255) `&]_[*@3 k], [*@4 T][@(0.0.255) `&`&]_[*@3 x])&]
[s2; Inserts a copy of key`-value pair at upper bound key position
and returns reference to element value.&]
[s3; &]

View file

@ -1,5 +1,4 @@
topic "SortedVectorMap";
[2 $$0,0#00000000000000000000000000000000:Default]
[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class]
[l288;2 $$2,2#27521748481378242620020725143825:desc]
[0 $$3,0#96390100711032703541132217272105:end]
@ -9,6 +8,7 @@ topic "SortedVectorMap";
[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param]
[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam]
[b42;2 $$9,9#13035079074754324216151401829390:normal]
[2 $$0,0#00000000000000000000000000000000:Default]
[{_}%EN-US
[ {{10000@(113.42.0) [s0; [*@7;4 SortedVectorMap]]}}&]
[s1;@(0.0.255)3%- &]
@ -28,6 +28,8 @@ keys and values have to be [^topic`:`/`/Core`/srcdoc`/Moveable`$en`-us^ Moveable
[s3;%- &]
[s5;:SortedVectorMap`:`:Add`(const K`&`,const T`&`):%- [*@4 T][@(0.0.255) `&]_[* Add]([@(0.0.255) c
onst]_[*@4 K][@(0.0.255) `&]_[*@3 k], [@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 x])&]
[s5;:Upp`:`:SortedVectorMap`:`:Add`(const K`&`,T`&`&`):%- [*@4 T][@(0.0.255) `&]_[* Add]([@(0.0.255) c
onst]_[*@4 K][@(0.0.255) `&]_[*@3 k], [*@4 T][@(0.0.255) `&`&]_[*@3 x])&]
[s2; Inserts a copy of key`-value pair at upper bound key position
and returns reference to element value.&]
[s3; &]