Core: Fixed ValueMap::RemoveKey issue

git-svn-id: svn://ultimatepp.org/upp/trunk@7641 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-09-05 13:00:16 +00:00
parent 5a2096839c
commit ca4d6935c7
4 changed files with 19 additions and 5 deletions

View file

@ -251,6 +251,11 @@ void ValueArray::Remove(int i, int count)
Clone().Remove(i, count); Clone().Remove(i, count);
} }
void ValueArray::Remove(const Vector<int>& ii)
{
Clone().Remove(ii);
}
void ValueArray::Insert(int i, const ValueArray& va) void ValueArray::Insert(int i, const ValueArray& va)
{ {
if(va.data == data) { if(va.data == data) {
@ -571,12 +576,12 @@ int ValueMap::RemoveKey(const Value& key)
rk.Add(q); rk.Add(q);
q = d.key.FindNext(q); q = d.key.FindNext(q);
} }
int count = rk.GetCount(); if(rk.GetCount()) {
if(count) { Sort(rk);
d.key.Remove(rk); d.key.Remove(rk);
d.value.data->data.Remove(rk); d.value.Remove(rk);
} }
return count; return rk.GetCount();
} }
void ValueMap::Remove(int i) void ValueMap::Remove(int i)

View file

@ -246,6 +246,7 @@ public:
Vector<Value> Pick(); Vector<Value> Pick();
void Remove(int i, int count = 1); void Remove(int i, int count = 1);
void Remove(const Vector<int>& ii);
void Insert(int i, const ValueArray& va); void Insert(int i, const ValueArray& va);
void Append(const ValueArray& va) { Insert(GetCount(), va); } void Append(const ValueArray& va) { Insert(GetCount(), va); }

View file

@ -1220,7 +1220,10 @@ mode`_t_[*@3 acm]_`=_[@3 0644])&]
and specific POSIX access rights. [%-*@3 mode] can be one of READ, and specific POSIX access rights. [%-*@3 mode] can be one of READ,
CREATE, APPEND, READWRITE possibly combined (using `'`|`') with CREATE, APPEND, READWRITE possibly combined (using `'`|`') with
flag NOWRITESHARE. This flag uses flock system call to enforce flag NOWRITESHARE. This flag uses flock system call to enforce
exclusive write access to the file.&] exclusive write access to the file. In READ, if file does not
exist, function fails. In CREATE mode, files is always created
empty. In APPEND and READWRITE modes, file is created if it does
not already exist.&]
[s7; [%-*C@3 filename]-|The name of the file.&] [s7; [%-*C@3 filename]-|The name of the file.&]
[s7; [%-*C@3 mode]-|Open mode.&] [s7; [%-*C@3 mode]-|Open mode.&]
[s7; [%-*C@3 acm]-|Access rights.&] [s7; [%-*C@3 acm]-|Access rights.&]

View file

@ -152,6 +152,11 @@ required.&]
[s2;%% Removes [%-*@3 count] elements at [%-*@3 i].&] [s2;%% Removes [%-*@3 count] elements at [%-*@3 i].&]
[s3;%% &] [s3;%% &]
[s4; &] [s4; &]
[s5;:ValueArray`:`:Remove`(const Vector`<int`>`&`): [@(0.0.255) void]_[* Remove]([@(0.0.255) c
onst]_[_^Vector^ Vector]<[@(0.0.255) int]>`&_[*@3 ii])&]
[s2;%% Removes the sorted set of indicies.&]
[s3;%% &]
[s4; &]
[s5;:ValueArray`:`:Insert`(int`,const ValueArray`&`): [@(0.0.255) void]_[* Insert]([@(0.0.255) i [s5;:ValueArray`:`:Insert`(int`,const ValueArray`&`): [@(0.0.255) void]_[* Insert]([@(0.0.255) i
nt]_[*@3 i], [@(0.0.255) const]_[_^ValueArray^ ValueArray][@(0.0.255) `&]_[*@3 va])&] nt]_[*@3 i], [@(0.0.255) const]_[_^ValueArray^ ValueArray][@(0.0.255) `&]_[*@3 va])&]
[s2;%% Inserts another ValueArra [%-*@3 va] at [%-*@3 i].&] [s2;%% Inserts another ValueArra [%-*@3 va] at [%-*@3 i].&]