Core: More container Adds/Inserts/Sets now return T&

git-svn-id: svn://ultimatepp.org/upp/trunk@3347 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2011-04-17 19:48:40 +00:00
parent c5637228ad
commit 57a59b99ef
9 changed files with 122 additions and 87 deletions

View file

@ -103,8 +103,8 @@ protected:
public:
HashFn hashfn;
void Add(const T& x, unsigned _hash);
void Add(const T& x);
T& Add(const T& x, unsigned _hash);
T& Add(const T& x);
int FindAdd(const T& key, unsigned _hash);
int FindAdd(const T& key);
AIndex& operator<<(const T& x) { Add(x); return *this; }
@ -121,8 +121,8 @@ public:
int FindLast(const T& x) const;
int FindPrev(int i) const;
void Set(int i, const T& x, unsigned _hash);
void Set(int i, const T& x);
T& Set(int i, const T& x, unsigned _hash);
T& Set(int i, const T& x);
const T& operator[](int i) const { return key[i]; }
int GetCount() const { return key.GetCount(); }
@ -143,8 +143,8 @@ public:
Vector<int> GetUnlinked() const { return hash.GetUnlinked(); }
void Sweep();
void Insert(int i, const T& k, unsigned h);
void Insert(int i, const T& k);
T& Insert(int i, const T& k, unsigned h);
T& Insert(int i, const T& k);
void Remove(int i);
void Remove(int i, int count);
void Remove(const int *sorted_list, int count);
@ -218,15 +218,15 @@ class ArrayIndex : MoveableAndDeepCopyOption< ArrayIndex<T, HashFn > >,
public AIndex<T, Array<T>, HashFn> {
typedef AIndex< T, Array<T>, HashFn > B;
public:
void Add(const T& x, unsigned _hash) { B::Add(x, _hash); }
void Add(const T& x) { B::Add(x); }
void Set(int i, const T& x, unsigned _hash) { B::Set(i, x, _hash); }
void Set(int i, const T& x) { B::Set(i, x); }
T& Add(const T& x, unsigned _hash) { return B::Add(x, _hash); }
T& Add(const T& x) { return B::Add(x); }
T& Set(int i, const T& x, unsigned _hash) { return B::Set(i, x, _hash); }
T& Set(int i, const T& x) { return B::Set(i, x); }
void Add(T *newt, unsigned _hash);
void Add(T *newt);
void Set(int i, T *newt, unsigned _hash);
void Set(int i, T *newt);
T& Add(T *newt, unsigned _hash);
T& Add(T *newt);
T& Set(int i, T *newt, unsigned _hash);
T& Set(int i, T *newt);
T *PopDetach() { B::hash.Drop(1); return B::key.PopDetach(); }
T *Detach(int i) { B::hash.Remove(i); return B::key.Detach(i); }

View file

@ -126,14 +126,15 @@ AIndex<T, V, HashFn>::AIndex(const V& s, int) : key(s, 1) {
}
template <class T, class V, class HashFn>
void AIndex<T, V, HashFn>::Add(const T& x, unsigned _hash) {
key.Add(x);
T& AIndex<T, V, HashFn>::Add(const T& x, unsigned _hash) {
T& t = key.Add(x);
hash.Add(_hash);
return t;
}
template <class T, class V, class HashFn>
void AIndex<T, V, HashFn>::Add(const T& x) {
Add(x, hashfn(x));
T& AIndex<T, V, HashFn>::Add(const T& x) {
return Add(x, hashfn(x));
}
template <class T, class V, class HashFn>
@ -214,14 +215,16 @@ int AIndex<T, V, HashFn>::FindAdd(const T& key) {
}
template <class T, class V, class HashFn>
void AIndex<T, V, HashFn>::Set(int i, const T& x, unsigned _hash) {
key[i] = x;
T& AIndex<T, V, HashFn>::Set(int i, const T& x, unsigned _hash) {
T& t = key[i];
t = x;
hash.Set(i, _hash);
return t;
}
template <class T, class V, class HashFn>
void AIndex<T, V, HashFn>::Set(int i, const T& x) {
Set(i, x, hashfn(x));
T& AIndex<T, V, HashFn>::Set(int i, const T& x) {
return Set(i, x, hashfn(x));
}
#ifdef UPP
@ -264,15 +267,17 @@ void AIndex<T, V, HashFn>::Sweep()
}
template <class T, class V, class HashFn>
void AIndex<T, V, HashFn>::Insert(int i, const T& k, unsigned h) {
T& AIndex<T, V, HashFn>::Insert(int i, const T& k, unsigned h) {
key.Insert(i, k);
hash.Insert(i, h);
return key[i];
}
template <class T, class V, class HashFn>
void AIndex<T, V, HashFn>::Insert(int i, const T& k) {
T& AIndex<T, V, HashFn>::Insert(int i, const T& k) {
key.Insert(i, k);
hash.Insert(i, hashfn(k));
return key[i];
}
template <class T, class V, class HashFn>
@ -324,25 +329,26 @@ int AIndex<T, V, HashFn>::RemoveKey(const T& k)
// ------------------
template <class T, class HashFn>
void ArrayIndex<T, HashFn>::Add(T *newt, unsigned _hash) {
B::key.Add(newt);
T& ArrayIndex<T, HashFn>::Add(T *newt, unsigned _hash) {
B::hash.Add(_hash);
return B::key.Add(newt);
}
template <class T, class HashFn>
void ArrayIndex<T, HashFn>::Add(T *newt) {
Add(newt, B::hashfn(*newt));
T& ArrayIndex<T, HashFn>::Add(T *newt) {
return Add(newt, B::hashfn(*newt));
}
template <class T, class HashFn>
void ArrayIndex<T, HashFn>::Set(int i, T *newt, unsigned _hash) {
B::key.Set(i, newt);
T& ArrayIndex<T, HashFn>::Set(int i, T *newt, unsigned _hash) {
T& t = B::key.Set(i, newt);
B::hash.Set(i, _hash);
return t;
}
template <class T, class HashFn>
void ArrayIndex<T, HashFn>::Set(int i, T *newt) {
Set(i, newt, B::hashfn(*newt));
T& ArrayIndex<T, HashFn>::Set(int i, T *newt) {
return Set(i, newt, B::hashfn(*newt));
}
// --------------------

View file

@ -5,8 +5,8 @@ protected:
V value;
public:
void Add(const K& k, const T& x) { key.Add(k); value.Add(x); }
void AddPick(const K& k, pick_ T& x) { key.Add(k); value.AddPick(x); }
T& Add(const K& k, const T& x) { key.Add(k); return value.Add(x); }
T& AddPick(const K& k, pick_ T& x) { key.Add(k); return value.AddPick(x); }
T& Add(const K& k) { key.Add(k); return value.Add(); }
int Find(const K& k, unsigned h) const { return key.Find(k, h); }
@ -59,7 +59,7 @@ public:
void Sweep();
T& Insert(int i, const K& k) { key.Insert(i, k); return value.Insert(i); }
void Insert(int i, const K& k, const T& x) { key.Insert(i, k); value.Insert(i, x); }
T& Insert(int i, const K& k, const T& x) { key.Insert(i, k); return value.Insert(i, x); }
void Remove(int i) { key.Remove(i); value.Remove(i); }
void Remove(int i, int count) { key.Remove(i, count); value.Remove(i, count); }
void Remove(const int *sl, int n) { key.Remove(sl, n); value.Remove(sl, n); }
@ -155,12 +155,12 @@ class ArrayMap : public MoveableAndDeepCopyOption< ArrayMap<K, T, HashFn> >,
public AMap< K, T, Array<T>, HashFn > {
typedef AMap< K, T, Array<T>, HashFn > B;
public:
void Add(const K& k, const T& x) { B::Add(k, x); }
T& Add(const K& k, const T& x) { return B::Add(k, x); }
T& Add(const K& k) { return B::Add(k); }
T& Add(const K& k, T *newt) { B::key.Add(k); B::value.Add(newt); return *newt; }
template <class TT> TT& Create(const K& k) { TT *q = new TT; B::key.Add(k); B::value.Add(q); return *q; }
void Set(int i, T *ptr) { B::value.Set(i, ptr); }
T& Set(int i, T *ptr) { return B::value.Set(i, ptr); }
T *PopDetach() { B::key.Drop(); return B::value.PopDetach(); }
T *Detach(int i) { B::key.Remove(i); return B::value.Detach(i); }

View file

@ -209,7 +209,7 @@ public:
T *Detach(int i) { T *t = &Get(i); vector.Remove(i); return t; }
T& Set(int i, T *newt) { delete (T *)vector[i]; vector[i] = newt; return *newt; }
void Insert(int i, T *newt);
T& Insert(int i, T *newt);
void Drop(int n = 1) { Trim(GetCount() - n); }
T& Top() { return Get(GetCount() - 1); }

View file

@ -457,9 +457,10 @@ T& Array<T>::InsertPick(int i, pick_ T& x)
}
template <class T>
void Array<T>::Insert(int i, T *newt) {
T& Array<T>::Insert(int i, T *newt) {
vector.InsertN(i, 1);
vector[i] = newt;
return *newt;
}
template <class T>

View file

@ -88,12 +88,13 @@ constructor.&]
[s0; &]
[ {{10000F(128)G(128)@1 [s0; [* Public Member List]]}}&]
[s3;%- &]
[s5;:AIndex`:`:Add`(const T`&`,unsigned`):%- [@(0.0.255) void]_[* Add]([@(0.0.255) const]_[*@4 T
][@(0.0.255) `&]_[*@3 x], [@(0.0.255) unsigned]_[*@3 `_hash])&]
[s5;:AIndex`:`:Add`(const T`&`,unsigned`):%- [*@4 T][@(0.0.255) `&]_[* Add]([@(0.0.255) const
]_[*@4 T][@(0.0.255) `&]_[*@3 x], [@(0.0.255) unsigned]_[*@3 `_hash])&]
[s2; Adds a new element [%-*@3 x] with a precomputed hash value [%-*@3 `_hash].
The performance benefit of this variant is that sometimes you
can compute hash`-value as the part of an other process, like
fetching strings from an input stream.&]
fetching strings from an input stream. Returns a reference to
the element.&]
[s6; Requires T to have deep copy constructor.&]
[s6; Invalidates iterators to AIndex.&]
[s6; Invalidates references to Index.&]
@ -101,9 +102,10 @@ fetching strings from an input stream.&]
by HashFn.&]
[s3;%- &]
[s4;%- &]
[s5;:AIndex`:`:Add`(const T`&`):%- [@(0.0.255) void]_[* Add]([@(0.0.255) const]_[*@4 T][@(0.0.255) `&
[s5;:AIndex`:`:Add`(const T`&`):%- [*@4 T][@(0.0.255) `&]_[* Add]([@(0.0.255) const]_[*@4 T][@(0.0.255) `&
]_[*@3 x])&]
[s2; Adds a new element [%-*@3 x ]to AIndex.&]
[s2; Adds a new element [%-*@3 x ]to AIndex. Returns a reference to
the element.&]
[s6; Requires T to have deep copy constructor.&]
[s6; Invalidates iterators to AIndex.&]
[s6; Invalidates references to Index.&]
@ -271,13 +273,13 @@ or placed element is returned.&]
[s6; Invalidates references to Index.&]
[s3;%- &]
[s4;%- &]
[s5;:AIndex`:`:Set`(int`,const T`&`,unsigned`):%- [@(0.0.255) void]_[* Set]([@(0.0.255) int
]_[*@3 i], [@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 x], [@(0.0.255) unsigned]_[*@3 `_hash
])&]
[s5;:AIndex`:`:Set`(int`,const T`&`,unsigned`):%- [*@4 T][@(0.0.255) `&]_[* Set]([@(0.0.255) i
nt]_[*@3 i], [@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 x], [@(0.0.255) unsigned]_[*@3 `_ha
sh])&]
[s2; Replaces the element at the specified position with a new element
with value [%-*@3 x], using a precomputed [%-*@3 `_hash]. Speed of
this operation depends on the total number of elements with the
same value as the specified one.&]
same value as the specified one. Returns a reference to the element.&]
[s6; Requires T to have deep copy constructor.&]
[s6; Invalidates iterators to AIndex.&]
[s6; Invalidates references to Index.&]
@ -285,11 +287,12 @@ same value as the specified one.&]
by HashFn.&]
[s3;%- &]
[s4;%- &]
[s5;:AIndex`:`:Set`(int`,const T`&`):%- [@(0.0.255) void]_[* Set]([@(0.0.255) int]_[*@3 i],
[@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 x])&]
[s5;:AIndex`:`:Set`(int`,const T`&`):%- [*@4 T][@(0.0.255) `&]_[* Set]([@(0.0.255) int]_[*@3 i],
[@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 x])&]
[s2; Replaces the element at the specified position with a new element
with value [%-*@3 x]. Speed of this operation depends on the total
number of elements with the same value as the specified one.&]
number of elements with the same value as the specified one.
Returns a reference to the element.&]
[s6; Requires T to have deep copy constructor.&]
[s6; Invalidates iterators to AIndex.&]
[s6; Invalidates references to Index.&]
@ -349,10 +352,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`:`:Insert`(int`,const T`&`,unsigned`):%- [@(0.0.255) void]_[* Insert]([@(0.0.255) i
[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
[%-*@3 i], using a precomputed hash [%-*@3 h]. This is a slow operation.&]
[%-*@3 i], using a precomputed hash [%-*@3 h]. This is a slow operation.
Returns a reference to the element.&]
[s6; Requires T to have deep copy constructor.&]
[s6; Invalidates iterators to AIndex.&]
[s6; Invalidates references to Index.&]
@ -360,10 +364,11 @@ nt]_[*@3 i], [@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 k], [@(0.0.255) unsi
by HashFn.&]
[s3;%- &]
[s4;%- &]
[s5;:AIndex`:`:Insert`(int`,const T`&`):%- [@(0.0.255) void]_[* Insert]([@(0.0.255) int]_[*@3 i
], [@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 k])&]
[s5;:AIndex`:`:Insert`(int`,const T`&`):%- [*@4 T][@(0.0.255) `&]_[* Insert]([@(0.0.255) int]_
[*@3 i], [@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 k])&]
[s2; Inserts an element with value [%-*@3 k] at the specified position
[%-*@3 i]. This is a slow operation.&]
[%-*@3 i]. This is a slow operation. Returns a reference to the
element.&]
[s6; Requires T to have deep copy constructor.&]
[s6; Invalidates iterators to AIndex.&]
[s6; Invalidates references to Index.&]

View file

@ -67,9 +67,10 @@ must have same number of elements.&]
[s0; &]
[ {{10000F(128)G(128)@1 [s0; [* Public Method List]]}}&]
[s3;%- &]
[s5;:AMap`:`:Add`(const K`&`,const T`&`):%- [@(0.0.255) void]_[* Add]([@(0.0.255) const]_[*@4 K
][@(0.0.255) `&]_[*@3 k], [@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 x])&]
[s2; Adds a key and value pair to the AMap.&]
[s5;:AMap`:`:Add`(const K`&`,const T`&`):%- [*@4 T][@(0.0.255) `&]_[* Add]([@(0.0.255) const]_
[*@4 K][@(0.0.255) `&]_[*@3 k], [@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 x])&]
[s2; Adds a key and value pair to the AMap. Returns a reference to
the element.&]
[s6; Invalidates iterators to AIndex.&]
[s6; T must have deep copy constructor.&]
[s6; Invalidates iterators to AMap.&]
@ -79,11 +80,11 @@ must have same number of elements.&]
[s7; [*C@3 x]-|Value.&]
[s3;%- &]
[s4;%- &]
[s5;:AMap`:`:AddPick`(const K`&`,pick`_ T`&`):%- [@(0.0.255) void]_[* AddPick]([@(0.0.255) c
[s5;:AMap`:`:AddPick`(const K`&`,pick`_ T`&`):%- [*@4 T][@(0.0.255) `&]_[* AddPick]([@(0.0.255) c
onst]_[*@4 K][@(0.0.255) `&]_[*@3 k], [@(0.128.128) pick`_]_[*@4 T][@(0.0.255) `&]_[*@3 x])&]
[s2; Adds a key and value pair to the AMap. Value is transfered by
pick constructor in low constant time, but the source value is
destroyed.&]
destroyed. Returns a reference to the element.&]
[s6; T must have pick constructor.&]
[s6; Invalidates iterators to AMap.&]
[s6; Invalidates references to keys.&]
@ -527,11 +528,16 @@ stay in AIndex but are ignored by any Find operations.&]
[s7; [*/ Return value]-|true if element is unlinked.&]
[s3;%- &]
[s4;%- &]
[s5;:AMap`:`:Sweep`(`):%- [@(0.0.255) void]_[* Sweep]()&]
[s2; Removes all unlinked elements from the container.&]
[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
value at the specified position. This is a slow operation, especially
when combined with any search operations.&]
when combined with any search operations. Returns a reference
to the element.&]
[s6; Requires T to have default constructor.&]
[s6; Invalidates iterators to AMap.&]
[s6; Invalidates references to keys.&]
@ -540,12 +546,13 @@ when combined with any search operations.&]
[s7; [*C@3 k]-|Key to insert.&]
[s3;%- &]
[s4;%- &]
[s5;:AMap`:`:Insert`(int`,const K`&`,const T`&`):%- [@(0.0.255) void]_[* Insert]([@(0.0.255) i
[s5;:AMap`:`:Insert`(int`,const K`&`,const T`&`):%- [*@4 T][@(0.0.255) `&]_[* Insert]([@(0.0.255) i
nt]_[*@3 i], [@(0.0.255) const]_[*@4 K][@(0.0.255) `&]_[*@3 k], [@(0.0.255) const]_[*@4 T][@(0.0.255) `&
]_[*@3 x])&]
[s2; Inserts an element with the specified key and value copy constructed
from [*/ x] at the specified position. This is a slow operation,
especially when combined with any search operations.&]
especially when combined with any search operations. Returns
a reference to the element.&]
[s6; Requires T to have deep copy constructor.&]
[s6; Invalidates iterators to AMap.&]
[s6; Invalidates references to keys.&]
@ -564,6 +571,14 @@ operation, especially when combined with any search operations.&]
[s7; [*C@3 i]-|Position of element to remove.&]
[s3;%- &]
[s4;%- &]
[s5;:AMap`:`:Remove`(int`,int`):%- [@(0.0.255) void]_[* Remove]([@(0.0.255) int]_[*@3 i],
[@(0.0.255) int]_[*@3 count])&]
[s2; Removes [%-*@3 count] elements at [%-*@3 i].&]
[s6; Invalidates iterators to AMap.&]
[s6; Invalidates references to keys.&]
[s6; Invalidates references to VectorMap values.&]
[s3; &]
[s4;%- &]
[s5;:AMap`:`:Remove`(const int`*`,int`):%- [@(0.0.255) void]_[* Remove]([@(0.0.255) const]_
[@(0.0.255) int]_`*[*@3 sl], [@(0.0.255) int]_[*@3 n])&]
[s2; Removes number of elements from AMap. Time of operation only

View file

@ -72,32 +72,33 @@ copy constructor.&]
[s0; &]
[ {{10000F(128)G(128)@1 [s0;%% [* Public Member List]]}}&]
[s4;H0; &]
[s5;:ArrayIndex`:`:Add`(const T`&`,unsigned`): [@(0.0.255) void]_[* Add]([@(0.0.255) const]_
[*@4 T][@(0.0.255) `&]_[*@3 x], [@(0.0.255) unsigned]_[*@3 `_hash])&]
[s5;:ArrayIndex`:`:Add`(const T`&`,unsigned`): [*@4 T][@(0.0.255) `&]_[* Add]([@(0.0.255) con
st]_[*@4 T][@(0.0.255) `&]_[*@3 x], [@(0.0.255) unsigned]_[*@3 `_hash])&]
[s2;%% Adds a new element with a precomputed hash value. The precomputed
hash value must be the same as the hash value that would be the
result of HashFn. The benefit of using a precomputed hash value
is that sometimes you can compute hash`-value as the part of
an other process, like fetching a string from an input stream.
This method has to be reimplemented in ArrayIndex (using simple
forwarding) due to overloading of [* Add] in other forms.&]
forwarding) due to overloading of [* Add] in other forms. Returns
a reference to the element.&]
[s6;%% Requires T to have deep copy constructor.&]
[s6;%% Invalidates iterators to the ArrayIndex.&]
[s7;%% [*C@3 x]-|Element to add.&]
[s7;%% [*C@3 `_hash]-|Precomputed hash value.&]
[s3; &]
[s4; &]
[s5;:ArrayIndex`:`:Add`(const T`&`): [@(0.0.255) void]_[* Add]([@(0.0.255) const]_[*@4 T][@(0.0.255) `&
[s5;:ArrayIndex`:`:Add`(const T`&`): [*@4 T][@(0.0.255) `&]_[* Add]([@(0.0.255) const]_[*@4 T][@(0.0.255) `&
]_[*@3 x])&]
[s2;%% Adds a new element to Index. This method has to be reimplemented
in ArrayIndex (using simple forwarding) due to overloading of
[* Add] in other forms.&]
[* Add] in other forms. Returns a reference to the element.&]
[s6;%% Requires T to have deep copy constructor.&]
[s6;%% Invalidates iterators to the ArrayIndex.&]
[s7;%% [*C@3 x]-|Element to add.&]
[s3; &]
[s4; &]
[s5;:ArrayIndex`:`:Set`(int`,const T`&`,unsigned`): [@(0.0.255) void]_[* Set]([@(0.0.255) i
[s5;:ArrayIndex`:`:Set`(int`,const T`&`,unsigned`): [*@4 T][@(0.0.255) `&]_[* Set]([@(0.0.255) i
nt]_[*@3 i], [@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 x], [@(0.0.255) unsigned]_[*@3 `_ha
sh])&]
[s2;%% Replaces the element at the specified position with a new
@ -105,7 +106,8 @@ element with the specified value, using a precomputed hash`-value.
Speed of this operation depends on the total number of elements
with the same value as the specified one in ArrayIndex. This
method has to be reimplemented in ArrayIndex (using simple redirection)
due to overloading of [* Set] in other forms.&]
due to overloading of [* Set] in other forms. Returns a reference
to the element.&]
[s6;%% Requires T to have deep copy constructor.&]
[s6;%% Invalidates iterators to the ArrayIndex.&]
[s7;%% [*C@3 i]-|Position of element.&]
@ -113,53 +115,57 @@ due to overloading of [* Set] in other forms.&]
[s7;%% [*C@3 `_hash]-|Precomputed hash value.&]
[s3; &]
[s4; &]
[s5;:ArrayIndex`:`:Set`(int`,const T`&`): [@(0.0.255) void]_[* Set]([@(0.0.255) int]_[*@3 i],
[@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 x])&]
[s5;:ArrayIndex`:`:Set`(int`,const T`&`): [*@4 T][@(0.0.255) `&]_[* Set]([@(0.0.255) int]_[*@3 i
], [@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 x])&]
[s2;%% Replaces element at specified position with new element with
specified value. Speed of this operation depends on the total
number of elements with the same value as the specified one in
ArrayIndex. This method has to be reimplemented in ArrayIndex
(using simple redirection) due to overloading of [* Set] in other
forms.&]
forms. Returns a reference to the element.&]
[s6;%% Requires T to have deep copy constructor.&]
[s6;%% Invalidates iterators to the ArrayIndex.&]
[s7;%% [*C@3 i]-|Position of element.&]
[s7;%% [*C@3 x]-|Value to set.&]
[s3; &]
[s4; &]
[s5;:ArrayIndex`:`:Add`(T`*`,unsigned`): [@(0.0.255) void]_[* Add]([*@4 T]_`*[*@3 newt],
[s5;:ArrayIndex`:`:Add`(T`*`,unsigned`): [*@4 T][@(0.0.255) `&]_[* Add]([*@4 T]_`*[*@3 newt],
[@(0.0.255) unsigned]_[*@3 `_hash])&]
[s2;%% Adds a new element created on the heap to the ArrayIndex using
a precomputed hash value. The element is specified by a pointer
to the object. ArrayIndex takes over ownership of the pointed
element. This variant allows the use of an ArrayIndex as a polymorphic
container, because the type of the added element can be either
T or a type derived from T. No constructor is applied. &]
T or a type derived from T. No constructor is applied. Returns
a reference to the element.&]
[s7;%% [*C@3 newt]-|Element created on the heap.&]
[s3; &]
[s4; &]
[s5;:ArrayIndex`:`:Add`(T`*`): [@(0.0.255) void]_[* Add]([*@4 T]_`*[*@3 newt])&]
[s5;:ArrayIndex`:`:Add`(T`*`): [*@4 T][@(0.0.255) `&]_[* Add]([*@4 T]_`*[*@3 newt])&]
[s2;%% Adds a new element to the ArrayIndex. The element is specified
by a pointer to the object. ArrayIndex takes over ownership of
the pointed element. This variant allows the use of an ArrayIndex
as a polymorphic container, because the type of the added element
can be either T or a type derived from T. No constructor is applied.
&]
Returns a reference to the element.&]
[s7;%% [*C@3 newt]-|Object to be added.&]
[s3; &]
[s4; &]
[s5;:ArrayIndex`:`:Set`(int`,T`*`,unsigned`): [@(0.0.255) void]_[* Set]([@(0.0.255) int]_[*@3 i
], [*@4 T]_`*[*@3 newt], [@(0.0.255) unsigned]_[*@3 `_hash])&]
[s5;:ArrayIndex`:`:Set`(int`,T`*`,unsigned`): [*@4 T][@(0.0.255) `&]_[* Set]([@(0.0.255) int]_
[*@3 i], [*@4 T]_`*[*@3 newt], [@(0.0.255) unsigned]_[*@3 `_hash])&]
[s2;%% Replaces the element at the specified position by an element
previously created on the heap. ArrayIndex takes over ownership
of the element. Returns a reference to the element.&]
[s7;%% [*C@3 i]-|Position.&]
[s7;%% [*C@3 newt]-|New element created on heap.&]
[s7;%% [*C@3 `_hash]-|Hash value&]
[s3; &]
[s4; &]
[s5;:ArrayIndex`:`:Set`(int`,T`*`): [@(0.0.255) void]_[* Set]([@(0.0.255) int]_[*@3 i],
[s5;:ArrayIndex`:`:Set`(int`,T`*`): [*@4 T][@(0.0.255) `&]_[* Set]([@(0.0.255) int]_[*@3 i],
[*@4 T]_`*[*@3 newt])&]
[s2;%% Replaces the element at the specified position by an element
previously created on the heap. ArrayIndex takes over ownership
of the element.&]
of the element. Returns a reference to the element.&]
[s7;%% [*C@3 i]-|Position.&]
[s7;%% [*C@3 newt]-|New element created on heap.&]
[s7;%% [*/ Return value]-|&]

View file

@ -84,11 +84,12 @@ The source containers should have equal number of elements.&]
[s0; &]
[ {{10000F(128)G(128)@1 [s0; [* Public Member List]]}}&]
[s3;%- &]
[s5;:ArrayMap`:`:Add`(const K`&`,const T`&`):%- [@(0.0.255) void]_[* Add]([@(0.0.255) const
]_[*@4 K][@(0.0.255) `&]_[*@3 k], [@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 x])&]
[s5;:ArrayMap`:`:Add`(const K`&`,const T`&`):%- [*@4 T][@(0.0.255) `&]_[* Add]([@(0.0.255) co
nst]_[*@4 K][@(0.0.255) `&]_[*@3 k], [@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[*@3 x])&]
[s2; Adds a key and value pair to the ArrayMap. This method has to
be reimplemented in ArrayMap (using simple forwarding) due to
overloading of [* Add] in other forms.&]
overloading of Add in other forms.Returns a reference to the
element.&]
[s6; T must have deep copy constructor.&]
[s6; Invalidates iterators to the ArrayMap.&]
[s6; Invalidates references to keys.&]
@ -120,10 +121,11 @@ from T as well. No constructor is applied.&]
[s7; [%-*@3 newt]-|Value.&]
[s3; &]
[s4;%- &]
[s5;:ArrayMap`:`:Set`(int`,T`*`):%- [@(0.0.255) void]_[* Set]([@(0.0.255) int]_[*@3 i],
[s5;:ArrayMap`:`:Set`(int`,T`*`):%- [*@4 T][@(0.0.255) `&]_[* Set]([@(0.0.255) int]_[*@3 i],
[*@4 T]_`*[*@3 ptr])&]
[s2; Sets value at specified index. Value is specified by a pointer
to the object. ArrayMap takes over ownership of this object.&]
to the object. ArrayMap takes over ownership of this object.
Returns a reference to the element.&]
[s7; [*C@3 i]-|Index.&]
[s7; [*C@3 ptr]-|Value.&]
[s3; &]