template int SortedIndex::FindAdd(const T& key) { int i = FindLowerBound(key); if(i == GetCount() || Less()(key, iv[i])) iv.Insert(i, key); return i; } template int SortedIndex::FindNext(int i) const { return i + 1 < iv.GetCount() && !Less()(iv[i], iv[i + 1]) ? i + 1 : -1; } template int SortedIndex::FindLast(const T& x) const { int i = iv.FindUpperBound(x, Less()); return i > 0 && !Less()(iv[i - 1], x) ? i - 1 : -1; } template int SortedIndex::FindPrev(int i) const { return i > 0 && !Less()(iv[i - 1], iv[i]) ? i - 1 : -1; } template int SortedIndex::RemoveKey(const T& x) { int l = FindLowerBound(x); int count = FindUpperBound(x) - l; Remove(l, count); return count; } template String SortedIndex::ToString() const { return AsStringArray(*this); } template void Slaved_InVector__::Insert(int blki, int pos) { data.data[blki].Insert(pos); res = &data.data[blki][pos]; } template void Slaved_InVector__::Split(int blki, int nextsize) { Vector& x = data.data.Insert(blki + 1); x.InsertSplit(0, data.data[blki], nextsize); data.data[blki].Shrink(); } template void Slaved_InVector__::AddFirst() { data.data.Add().Add(); res = &data.data[0][0]; } template String SortedAMap::ToString() const { String r; r = "{"; for(int i = 0; i < GetCount(); i++) { if(i) r << ", "; r << GetKey(i) << ": " << (*this)[i]; } r << '}'; return r; } template SortedVectorMap::SortedVectorMap(SortedVectorMap&& s) { B::key = pick(s.key); B::value.data = pick(s.value.data); B::SetSlave(); } template SortedVectorMap& SortedVectorMap::operator=(SortedVectorMap&& s) { B::key = pick(s.key); B::value.data = pick(s.value.data); B::SetSlave(); return *this; } template SortedVectorMap::SortedVectorMap(const SortedVectorMap& s, int) { B::key = clone(s.key); B::value.data = clone(s.value.data); B::SetSlave(); } template int SortedVectorMap::FindAdd(const K& k, const T& init) { B::value.res = NULL; int q = B::key.FindAdd(k); if(B::value.res) *B::value.res = init; return q; } template void SortedVectorMap::Swap(SortedVectorMap& x) { B::value.data.Swap(x.value.data); B::key.Swap(x.B::key); B::SetSlave(); x.SetSlave(); } template void Slaved_InArray__::Insert(int blki, int pos) { if(!res) res = new T; data.iv.data[blki].Insert(pos, res); } template void Slaved_InArray__::Split(int blki, int nextsize) { Vector< typename InArray::PointerType >& x = data.iv.data.Insert(blki + 1); x.InsertSplit(0, data.iv.data[blki], nextsize); } template void Slaved_InArray__::Remove(int blki, int pos, int n) { Vector< typename InArray::PointerType >& b = data.iv.data[blki]; for(int i = 0; i < n; i++) if(b[i + pos]) delete (T *)b[i + pos]; b.Remove(pos, n); } template void Slaved_InArray__::AddFirst() { if(!res) res = new T; data.iv.data.Add().Add(res); } template int SortedArrayMap::FindAdd(const K& k, const T& init) { B::value.res = NULL; int q = B::key.FindAdd(k); if(B::value.res) *B::value.res = init; return q; } template SortedArrayMap::SortedArrayMap(SortedArrayMap&& s) { B::key = pick(s.key); B::value.data = pick(s.value.data); B::SetSlave(); } template SortedArrayMap& SortedArrayMap::operator=(SortedArrayMap&& s) { B::key = pick(s.key); B::value.data = pick(s.value.data); B::SetSlave(); return *this; } template SortedArrayMap::SortedArrayMap(const SortedArrayMap& s, int) { B::key = clone(s.key); B::value.data = clone(s.value.data); B::SetSlave(); } template void SortedArrayMap::Swap(SortedArrayMap& x) { B::value.data.Swap(x.value.data); B::key.Swap(x.B::key); B::SetSlave(); x.SetSlave(); } #ifdef UPP template void StreamSortedMap(Stream& s, T& cont) { int n = cont.GetCount(); s / n; if(n < 0) { s.LoadError(); return; } if(s.IsLoading()) { cont.Clear(); while(n--) { K key; s % key; s % cont.Add(key); } } else for(int i = 0; i < cont.GetCount(); i++) { K key = cont.GetKey(i); s % key; s % cont[i]; } } template void SortedVectorMap::Serialize(Stream& s) { StreamSortedMap >(s, *this); } template void SortedVectorMap::Xmlize(XmlIO& xio) { XmlizeSortedMap >(xio, "key", "value", *this); } template void SortedVectorMap::Jsonize(JsonIO& jio) { JsonizeSortedMap, K, T>(jio, *this, "key", "value"); } template void SortedArrayMap::Serialize(Stream& s) { StreamSortedMap >(s, *this); } template void SortedArrayMap::Xmlize(XmlIO& xio) { XmlizeSortedMap >(xio, "key", "value", *this); } template void SortedArrayMap::Jsonize(JsonIO& jio) { JsonizeSortedMap, K, T>(jio, *this, "key", "value"); } #endif