git-svn-id: svn://ultimatepp.org/upp/trunk@475 f0d560ea-af0d-0410-9eb7-867de7ffcac7

This commit is contained in:
cxl 2008-09-22 20:11:36 +00:00
parent 659a2b1cf6
commit 97132342e4
6 changed files with 5848 additions and 1114 deletions

View file

@ -1,17 +1,562 @@
topic "template <class T>"; topic "template <class T, class V, class HashFn> class AIndex";
[ $$0,0#00000000000000000000000000000000:Default] [2 $$0,0#00000000000000000000000000000000:Default]
[i448;a25;kKO9; $$1,0#37138531426314131252341829483380:class] [i448;a25;kKO9; $$1,0#37138531426314131252341829483380:class]
[l288;2 $$2,0#27521748481378242620020725143825:desc] [l288;2 $$2,0#27521748481378242620020725143825:desc]
[0 $$3,0#96390100711032703541132217272105:end] [0 $$3,0#96390100711032703541132217272105:end]
[H6;0 $$4,0#05600065144404261032431302351956:begin] [H6;0 $$4,0#05600065144404261032431302351956:begin]
[i448;a25;kKO9;2 $$5,0#37138531426314131252341829483370:item] [i448;a25;kKO9;2 $$5,0#37138531426314131252341829483370:item]
[l288;a17;*@5;1 $$6,6#70004532496200323422659154056402:requirement]
[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param]
[{_}%EN-US [{_}%EN-US
[s0;*@(128) &] [s5;%- [*@(64) template_<][*@(0.0.255) class][*@(64) _][*@4 T][*@(64) , ][*@(0.0.255) class][*@(64) _
[ {{10000F(128)G(128)@1 [s0; [* Constructor Detail]]}}&] ][*@4 V][*@(64) , ][*@(0.0.255) class][*@(64) _][*@4 HashFn][*@(64) >__][*@(0.0.255) class][*@(64) _
][* AIndex]&]
[s0;:`:`:AbortExc`:`:`:`:AbortExc`(`): [t class ][*t AIndex]&]
[s0; &] [s0; &]
[s5;K:`:`:Size`_`:`:`:`:Size`_`(`):%- &] [s0; [*C@4 T]-|Type of [^topic`:`/`/CoreTopics`/src`/AIndex`$en`-us^ elements]
[ {{10000F(128)G(128)@1 [s0; [* Public Field Detail]]}}&] to store. T must satisfy requirements for container flavor identified
by parameter V and must have [*C operator`=`=] defined.&]
[s0; [*C@4 V]-|Basic random access container.&]
[s0; [*C@4 HashFn]-|Hashing class. Must have defined [*C unsigned operator()(const
T`& x)] method returning hash value for elements.&]
[s0; This template class adds associative capabilities to basic random
access containers, forming flavors of Index. It is used as base
class for concrete index flavors, [* Index] and [* ArrayIndex].&]
[s0; It allows adding elements at the end of sequence in constant
amortized time like basic random container. Additionally, it
also allows fast retrieval of a position of the element with
specified value. Hashing is used for this operation. AIndex stores
hash`-values of elements, so it has no sense to cache them externally.&]
[s0; Building of internal hash maps of AIndex is always deferred
till search operation. This effectively avoids unneeded remapping
if large number of elements is added.&]
[s0; Removing elements from an AIndex causes an interesting problem.
While it is possible to simply remove (or insert) an element
at a specified position, such operation has to move a lot of
elements and also scratches internal hash maps. Thus removing
elements this way is slow, especially when combined with searching.&]
[s0; The solution for this problem is [*/ unlinking] of elements. Unlinked
elements are not removed from index, but they are [*/ ignored][/
]by search operations. Unlinking is a simple, constant time,
fast operation. Further, it is possible to place an element at
the first available unlinked position (rather than to the end
of sequence) using the [* Put] method, reusing unlinked position
in short constant time.&]
[s0; The only problem of unlinking is that it breaks the so`-called
[* multi`-key ordering]. This term means that if there are more
elements with the same value in the index and they are iterated
through using the FindNext method, their positions (got as the
result of Find and subsequent FindNext methods) are in ascending
order. The problem is that it is impossible to implement placing
elements at unlinked positions in short time while preserving
this ordering. On the other hand, usage scenarios for indexes
show that need for unlinking elements and multi`-key ordering
is almost always disjunct. For the rest of the cases, it is always
possible to restore ordering by the [* Reindex] or the [* Sweep]
method.&]
[s0; Like any other NTL container, AIndex is [*/^topic`:`/`/Core`/srcdoc`/Moveable`$en`-us^ m
oveable][*/ ]type with [*/^topic`:`/`/Core`/srcdoc`/Moveable`$en`-us^ pick
and optional deep copy] transfer semantics, although these features
are more important in derived concrete index flavors.&]
[s0; Members&]
[s0; &] [s0; &]
[s5;K:`:`:Size`_`:`:cx:@4%- &] [s3;%- &]
[ {{10000F(128)G(128)@1 [s0; [* Method Detail]]}}&] [s4;%- &]
[s5;:`:`:AIndex`:`:Add`(const T`&`,unsigned`):%- [@(0.0.255) void]_[* Add]([@(0.0.255) cons
t]_[*@4 T]`&_[*@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 this variant is that sometimes
you can compute hash`-value as the part of an other process,
like fetching strings from an input stream.&]
[s6; Requires T to have deep copy constructor.&]
[s6; Invalidates iterators to AIndex.&]
[s6; Invalidates references to Index.&]
[s7; [*C@3 x]-|Element to add.&]
[s7; [*C@3 `_hash]-|Precomputed hash value.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:Add`(const T`&`):%- [@(0.0.255) void]_[* Add]([@(0.0.255) const]_[*@4 T]`&
_[*@3 x])&]
[s2; Adds a new element to AIndex.&]
[s6; Requires T to have deep copy constructor.&]
[s6; Invalidates iterators to AIndex.&]
[s6; Invalidates references to Index.&]
[s7; [*C@3 x]-|Element to add.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:Find`(const T`&`,unsigned`)const:%- [@(0.0.255) int]_[* Find]([@(0.0.255) c
onst]_[*@4 T]`&_[*@3 x], [@(0.0.255) unsigned]_[*@3 `_hash])_[@(0.0.255) const]&]
[s2; Retrieves the position of the first element with the specified
value in AIndex, using a precomputed hash value. The precomputed
hash value must be the same as the hash value that would be result
of HashFn. If multi`-key ordering is not broken and more than
one element with the same value exists in AIndex, the lowest
position is retrieved. If the specified value does not exist
in AIndex, a negative number is returned. Unlinked elements are
ignored.&]
[s7; [*C@3 x]-|Element to find.&]
[s7; [*C@3 `_hash]-|Precomputed hash value.&]
[s7; [*/ Return value]-|Position of the element or negative value if
value is not in AIndex.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:Find`(const T`&`)const:%- [@(0.0.255) int]_[* Find]([@(0.0.255) const]_[*@4 T
]`&_[*@3 x])_[@(0.0.255) const]&]
[s2; Retrieves the position of the first element with the specified
value in AIndex. If multi`-key ordering is not broken and more
than one element with the same value exists in AIndex, lowest
position is retrieved. If the specified value does not exist
in AIndex, a negative number is returned. Unlinked elements are
ignored.&]
[s7; [*C@3 x]-|Element to find.&]
[s7; [*/ Return value]-|Position of the element or negative value if
value is not in AIndex.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:FindNext`(int`)const:%- [@(0.0.255) int]_[* FindNext]([@(0.0.255) int]_[*@3 i
])_[@(0.0.255) const]&]
[s2; Retrieves the position of the next element with the same value
as the element at specified position. If multi`-key ordering
is not broken and more than one element with that value exists
in AIndex, the lowest position greater than specified one is
retrieved, so positions returned by subsequent calls to FindNext
are in ascending order. When there are no more elements with
the required value, a negative number is returned. Unlinked elements
are ignored.&]
[s7; [*C@3 i]-|Position of the element.&]
[s7; [*/ Return value]-|Position of the next element with same value.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:FindLast`(const T`&`,unsigned`)const:%- [@(0.0.255) int]_[* FindLast](
[@(0.0.255) const]_[*@4 T]`&_[*@3 x], [@(0.0.255) unsigned]_[*@3 `_hash])_[@(0.0.255) const]&]
[s2; Retrieves the position of the last element with specified value
in AIndex, using a precomputed hash value. The precomputed hash
value must be the same as the hash value that would be the result
of HashFn. If multi`-key ordering is not broken and more than
one element with the same value exists in AIndex, the greatest
position is retrieved. If the specified value does not exist
in AIndex, a negative number is returned. Unlinked elements are
ignored.&]
[s7; [*C@3 x]-|Element to find.&]
[s7; [*C@3 `_hash]-|Precomputed hash value.&]
[s7; [*/ Return value]-|Position of the element or negative number if
value is not in AIndex.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:FindLast`(const T`&`)const:%- [@(0.0.255) int]_[* FindLast]([@(0.0.255) c
onst]_[*@4 T]`&_[*@3 x])_[@(0.0.255) const]&]
[s2; Retrieves the position of the last element with specified value
in AIndex. If multi`-key ordering is not broken and more than
one element with the same value exists in AIndex, the greatest
position is retrieved. If element does not exist in AIndex, a
negative number is returned. Unlinked elements are ignored.&]
[s7; [*C@3 x]-|Element to find.&]
[s7; [*C@3 `_hash]-|Precomputed hash value.&]
[s7; [*/ Return value]-|Position of the element or negative number if
value is not in AIndex.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:FindPrev`(int`)const:%- [@(0.0.255) int]_[* FindPrev]([@(0.0.255) int]_[*@3 i
])_[@(0.0.255) const]&]
[s2; Retrieves the position of the previous element with the same
value as the element at the specified position. If multi`-key
ordering is not broken and more than one element with that value
exists in AIndex, the greatest position lower than specified
one is retrieved (so that positions got by subsequent calls to
FindNext are in descending order). When there are no more elements
with required value, negative number is returned. Unlinked elements
are ignored.&]
[s7; [*C@3 i]-|Position of the element.&]
[s7; [*/ Return value]-|Position of the previous element with same value.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:FindAdd`(const T`&`,unsigned`):%- [@(0.0.255) int]_[* FindAdd]([@(0.0.255) c
onst]_[*@4 T]`&_[*@3 key], [@(0.0.255) unsigned]_[*@3 `_hash])&]
[s2; Retrieves position of first element with specified value in
AIndex, using a precomputed hash value. Precomputed hash value
must be same as hash value that would be result of HashFn. If
multi`-key ordering is not broken and more than one element with
the same value exists in AIndex, the lowest position is retrieved.
If element does not exist in AIndex, it is added to AIndex and
position of this newly added element is returned. Unlinked elements
are ignored.&]
[s7; [*C@3 key]-|Element to find or add.&]
[s7; [*C@3 `_hash]-|Precomputed hash value.&]
[s7; [*/ Return value]-|Position of the found or added element.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:FindAdd`(const T`&`):%- [@(0.0.255) int]_[* FindAdd]([@(0.0.255) const]_
[*@4 T]`&_[*@3 key])&]
[s2; Retrieves position of first element with specified value in
AIndex. If multi`-key ordering is not broken and more than one
element with the same value exists in AIndex, lowest position
is retrieved. If element does not exist in AIndex, it is added
to AIndex and position of this newly added element is returned.
Unlinked elements are ignored.&]
[s7; [*C@3 key]-|Element to find or add.&]
[s7; [*/ Return value]-|Position of the found or added element.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:operator`<`<`(const T`&`):%- [_^`:`:AIndex^ AIndex]`&_[* operator<<]([@(0.0.255) c
onst]_[*@4 T]`&_[*@3 x])&]
[s2; Operator replacement of [* void Add(const T`& x)]. By returning
reference to AIndex it allows adding multiple elements in a single
expression, thus e.g. allowing to construct a temporary Index
as part of an expression like Foo((Index<int>() << 1 << 2)).&]
[s6; Requires T to have deep copy constructor.&]
[s6; Invalidates iterators to AIndex.&]
[s6; Invalidates references to Index.&]
[s7; [*C@3 newt]-|Element to be added.&]
[s7; [*/ Return value]-|Reference to AIndex.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:Unlink`(int`):%- [@(0.0.255) void]_[* Unlink]([@(0.0.255) int]_[*@3 i])&]
[s2; Unlinks the element at the specified position. The unlinked
item stays in AIndex but is ignored by any Find operation.&]
[s7; [*C@3 i]-|Position of item to unlink.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:Put`(const T`&`,unsigned`):%- [@(0.0.255) int]_[* Put]([@(0.0.255) const
]_[*@4 T]`&_[*@3 x], [@(0.0.255) unsigned]_[*@3 `_hash])&]
[s2; If there are any unlinked elements in AIndex, one of them is
replaced by specified value. If there are no unlinked elements,
the element with the specified value is appended to the end of
AIndex using [* Add]. The precomputed hash should be same as the
result of HashFn. The position of the placed element is returned.&]
[s6; Invalidates multi`-key ordering.&]
[s6; Requires T to have deep copy constructor.&]
[s6; Invalidates iterators to AIndex.&]
[s6; Invalidates references to Index.&]
[s7; [*C@3 x]-|Element to put into AIndex.&]
[s7; [*C@3 `_hash]-|Precomputed hash value.&]
[s7; [*/ Return value]-|Position where the element was placed.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:Put`(const T`&`):%- [@(0.0.255) int]_[* Put]([@(0.0.255) const]_[*@4 T]`&_
[*@3 x])&]
[s2; If there are any unlinked elements in AIndex, one of them is
replaced by specified value. If there are no unlinked elements,
the element with the specified value is appended to the end of
AIndex using [* Add]. The position of the placed element is returned.&]
[s6; Invalidates multi`-key ordering.&]
[s6; Requires T to have deep copy constructor.&]
[s6; Invalidates iterators to AIndex.&]
[s7; [*C@3 x]-|Element to put into AIndex.&]
[s7; [*/ Return value]-|Position where element is placed.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:FindPut`(const T`&`,unsigned`):%- [@(0.0.255) int]_[* FindPut]([@(0.0.255) c
onst]_[*@4 T]`&_[*@3 key], [@(0.0.255) unsigned]_[*@3 `_hash])&]
[s2; Retrieves the position of the first element with the specified
value in AIndex, using a precomputed hash value. The precomputed
hash value must be the same as the hash value that would be the
result of HashFn. If the specified value does not exist in the
AIndex, it is placed to it using [* Put(const T`& x, unsigned `_hash).]
The position of the found or placed element is returned.&]
[s6;~~~.992; Invalidates multi`-key ordering.&]
[s6; Requires T to have deep copy constructor.&]
[s6; Invalidates iterators to AIndex.&]
[s6; Invalidates references to Index.&]
[s7; [*C@3 key]-|Element to find or put.&]
[s7; [*C@3 `_hash]-|Precomputed hash value.&]
[s7; [*/ Return value]-|Position of the found or placed element.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:FindPut`(const T`&`):%- [@(0.0.255) int]_[* FindPut]([@(0.0.255) const]_
[*@4 T]`&_[*@3 key])&]
[s2; Retrieves the position of the first element with the specified
value in AIndex. If the element does not exist in the AIndex,
it is placed to it using [* Put(const T`& x).] The position of
the found or placed element is returned.&]
[s6; Invalidates multi`-key ordering.&]
[s6; Requires T to have deep copy constructor.&]
[s6; Invalidates iterators to AIndex.&]
[s6; Invalidates references to Index.&]
[s7; [*C@3 key]-|Element to find or put.&]
[s7; [*C@3 `_hash]-|Precomputed hash value.&]
[s7; [*/ Return value]-|Position of the found or placed element.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:Set`(int`,const T`&`,unsigned`):%- [@(0.0.255) void]_[* Set]([@(0.0.255) i
nt]_[*@3 i], [@(0.0.255) const]_[*@4 T]`&_[*@3 x], [@(0.0.255) unsigned]_[*@3 `_hash])&]
[s2; Replaces the element at the specified position with a new 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.&]
[s6; Requires T to have deep copy constructor.&]
[s6; Invalidates iterators to AIndex.&]
[s6; Invalidates references to Index.&]
[s7; [*C@3 i]-|Position of the element.&]
[s7; [*C@3 x]-|Value to set.&]
[s7; [*C@3 `_hash]-|Precomputed hash value.&]
[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]`&_[*@3 x])&]
[s2; Replaces the element at the specified position with a new element
with the specified value. Speed of this operation depends on
total number of elements with the same value as specified the
specified one.&]
[s6; Requires T to have deep copy constructor.&]
[s6; Invalidates iterators to AIndex.&]
[s6; Invalidates references to Index.&]
[s7; [*C@3 i]-|Position of the element.&]
[s7; [*C@3 x]-|Value to set.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:operator`[`]`(int`)const:%- [@(0.0.255) const]_[*@4 T]`&_[* operator`[`]
]([@(0.0.255) int]_[*@3 i])_[@(0.0.255) const]&]
[s2; Returns the element at the specified position.&]
[s7; [*C@3 i]-|Position of the element.&]
[s7; [*/ Return value]-|Constant reference to element.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:GetCount`(`)const:%- [@(0.0.255) int]_[* GetCount]()_[@(0.0.255) const]&]
[s2; Returns number of elements in AIndex.&]
[s7; [*/ Return value]-|Actual number of elements.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:IsEmpty`(`)const:%- [@(0.0.255) bool]_[* IsEmpty]()_[@(0.0.255) const]&]
[s2; Tests whether AIndex is empty. Same as GetCount() `=`= 0.&]
[s7; [*/ Return value]-|true if AIndex is empty, false otherwise.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:Clear`(`):%- [@(0.0.255) void]_[* Clear]()&]
[s2; Removes all elements from AIndex.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:ClearIndex`(`):%- [@(0.0.255) void]_[* ClearIndex]()&]
[s2; Restores multi`-key ordering.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:UnlinkKey`(const T`&`,unsigned`):%- [@(0.0.255) int]_[* UnlinkKey]([@(0.0.255) c
onst]_[*@4 T]`&_[*@3 k], [@(0.0.255) unsigned]_[*@3 h])&]
[s2; Unlinks all elements with specified value using precomputed
hash`-value. Unlinked elements stay in AIndex but are ignored
by any Find operations. Precomputed hash value must be same as
hash value that would be result of HashFn. &]
[s7; [*C@3 k]-|Value of elements to unlink.&]
[s7; [*C@3 h]-|Precomputed hash value.&]
[s7; [*/ Return value]-|Number of elements unlinked.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:UnlinkKey`(const T`&`):%- [@(0.0.255) int]_[* UnlinkKey]([@(0.0.255) con
st]_[*@4 T]`&_[*@3 k])&]
[s2; Unlinks all elements with specified value. Unlinked elements
remain in the AIndex but are ignored by any Find operations.&]
[s7; [*C@3 k]-|Value of elements to unlink.&]
[s7; [*/ Return value]-|Number of elements unlinked.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:IsUnlinked`(int`)const:%- [@(0.0.255) bool]_[* IsUnlinked]([@(0.0.255) i
nt]_[*@3 i])_[@(0.0.255) const]&]
[s2; Tests whether the element at the specified position is unlinked.&]
[s7; [*C@3 i]-|Position.&]
[s7; [*/ Return value]-|true if element is unlinked.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:Sweep`(`):%- [@(0.0.255) void]_[* Sweep]()&]
[s2; Removes all unlinked elements from AIndex. Complexity of the
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
nt]_[*@3 i], [@(0.0.255) const]_[*@4 T]`&_[*@3 k], [@(0.0.255) unsigned]_[*@3 h])&]
[s2; Inserts an element with the specified value at the specified
position, using a precomputed hash value. The precomputed hash
value must be the same as the hash value that would be the result
of HashFn. This is a slow operation, especially when combined
with any search operations.&]
[s6; Requires T to have deep copy constructor.&]
[s6; Invalidates iterators to AIndex.&]
[s6; Invalidates references to Index.&]
[s7; [*C@3 i]-|Insert position.&]
[s7; [*C@3 k]-|Element to insert.&]
[s7; [*C@3 h]-|Precomputed hash value.&]
[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]`&_[*@3 k])&]
[s2; Inserts an element with the specified value at the specified
position. This is a slow operation, especially when combined
with any search operations.&]
[s6; Requires T to have deep copy constructor.&]
[s6; Invalidates iterators to AIndex.&]
[s6; Invalidates references to Index.&]
[s7; [*C@3 i]-|Insert position.&]
[s7; [*C@3 k]-|Element to insert.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:Remove`(int`):%- [@(0.0.255) void]_[* Remove]([@(0.0.255) int]_[*@3 i])&]
[s2; Removes the element at the specified position. This is a slow
operation, especially when combined with any search operations.&]
[s6; Invalidates iterators to AIndex.&]
[s6; Invalidates references to Index.&]
[s7; [*C@3 i]-|Position of the element to remove.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:Remove`(const int`*`,int`):%- [@(0.0.255) void]_[* Remove]([@(0.0.255) c
onst]_[@(0.0.255) int]_`*[*@3 sorted`_list], [@(0.0.255) int]_[*@3 count])&]
[s2; Removes multiple elements from AIndex. Time of operation only
slightly depends on the number of removed elements. This is a
slow operation, especially when combined with any search operations.&]
[s6; Invalidates iterators to AIndex.&]
[s6; Invalidates references to Index.&]
[s7; [*C@3 sorted`_list]-|Pointer to array of positions to remove, in
ascending order.&]
[s7; [*C@3 count]-|Number of elements to remove.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:Remove`(const`:`:Vector`<int`>`&`):%- [@(0.0.255) void]_[* Remove]([@(0.0.255) c
onst]_[_^`:`:Vector^ Vector]<int>`&_[*@3 sorted`_list])&]
[s2; Removes multiple elements from AIndex. Same as Remove(sorted`_list,
sorted`_list.GetCount()).&]
[s6; Invalidates iterators to AIndex.&]
[s6; Invalidates references to Index.&]
[s7; [*C@3 sorted`_list]-|Sorted Vector of positions to remove.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:RemoveKey`(const T`&`,unsigned`):%- [@(0.0.255) int]_[* RemoveKey]([@(0.0.255) c
onst]_[*@4 T]`&_[*@3 k], [@(0.0.255) unsigned]_[*@3 h])&]
[s2; Removes all elements with the specified value using a precomputed
hash`-value. The precomputed hash value must be the same as the
hash value that would be the result of HashFn. This is a slow
operation, especially when combined with any search operations.&]
[s7; [*C@3 k]-|Value of the elements to remove.&]
[s7; [*C@3 h]-|Precomputed hash value.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:RemoveKey`(const T`&`):%- [@(0.0.255) int]_[* RemoveKey]([@(0.0.255) con
st]_[*@4 T]`&_[*@3 k])&]
[s2; Removes all elements with the specified value. This is a slow
operation, especially when combined with any search operations.&]
[s7; [*C@3 k]-|Value of the elements to remove.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:Trim`(int`):%- [@(0.0.255) void]_[* Trim]([@(0.0.255) int]_[*@3 n])&]
[s2; Reduces the number of elements in AIndex to the specified number.
Requested number must be less than or equal to actual number
of elements in AIndex.&]
[s7; [*C@3 n]-|Requested number of elements.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:Drop`(int`):%- [@(0.0.255) void]_[* Drop]([@(0.0.255) int]_[*@3 n]_`=_[@3 1])
&]
[s2; Drops the specified number of elements from the end of the AIndex
(same as Trim(GetCount() `- n)).&]
[s7; [*C@3 n]-|Number of elements.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:Top`(`)const:%- [@(0.0.255) const]_[*@4 T]`&_[* Top]()_[@(0.0.255) const]&]
[s2; Returns a reference to the last element in the AIndex.&]
[s7; [*/ Return value]-|Reference of thr last element in the AIndex.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:Reserve`(int`):%- [@(0.0.255) void]_[* Reserve]([@(0.0.255) int]_[*@3 n])&]
[s2; Reserves capacity. If the requested capacity is greater than
current capacity, capacity is increased to the requested value.&]
[s7; [*C@3 n]-|Requested capacity.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:Shrink`(`):%- [@(0.0.255) void]_[* Shrink]()&]
[s2; Minimizes the memory consumption of AIndex by decreasing the
capacity to the number of elements.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:GetAlloc`(`)const:%- [@(0.0.255) int]_[* GetAlloc]()_[@(0.0.255) const]&]
[s2; Returns the current capacity of AIndex.&]
[s7; [*/ Return value]-|Capacity of AIndex.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:Serialize`(`:`:Stream`&`):%- [@(0.0.255) void]_[* Serialize]([_^`:`:Stream^ S
tream]`&_[*@3 s])&]
[s2; Serializes content of AIndex to/from Stream. Works only if NTL
is used as part of UPP.&]
[s6; Requires T to have serialization operator defined.&]
[s7; [*C@3 s]-|Target/source stream.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:PickKeys`(`)pick`_:%- [*@4 V]_[* PickKeys]()_pick`_&]
[s2; Returns a basic random access container of elements. Destroys
AIndex by picking.&]
[s7; [*/ Return value]-|Basic random access container of elements in
AIndex.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:GetKeys`(`)const:%- [@(0.0.255) const]_[*@4 V]`&_[* GetKeys]()_[@(0.0.255) c
onst]&]
[s2; Returns a constant reference to basic random access container
of elements.&]
[s7; [*/ Return value]-|Constant reference to a basic random access
container of elements.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:operator`=`(pick`_ V`&`):%- [_^`:`:AIndex^ AIndex]`&_[* operator`=](pi
ck`__[*@4 V]`&_[*@3 s])&]
[s2; Assigns basic random access container to AIndex. Transfers the
source container in short constant time, but destroys it by picking.&]
[s7; [*C@3 s]-|Source container.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:operator`<`<`=`(const V`&`):%- [_^`:`:AIndex^ AIndex]`&_[* operator<<`=
]([@(0.0.255) const]_[*@4 V]`&_[*@3 s])&]
[s2; Assigns the basic random access container to AIndex, while preserving
the value of the source container.&]
[s6; Requires T to have deep copy constructor or optional deep copy.&]
[s7; [*C@3 s]-|Source container.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:AIndex`(pick`_ V`&`):%- [* AIndex](pick`__[*@4 V]`&_[*@3 s])&]
[s2; Pick`-constructs AIndex from a basic random access container.
Transfers the source container in short constant time, but destroys
it by picking.&]
[s7; [*C@3 s]-|Source basic random access container.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:AIndex`(const V`&`,int`):%- [* AIndex]([@(0.0.255) const]_[*@4 V]`&_[*@3 s
], [@(0.0.255) int])&]
[s2; Deep`-copy constructs AIndex from basic random access container.&]
[s6; Requires T to have deep copy constructor or optional deep copy
constructor.&]
[s7; [*C@3 s]-|Source AIndex.&]
[s5;K%- typedef_T_ValueType&]
[s2; Typedef of T for use in templated algorithms.&]
[s5;K%- typedef_typename_[^V`:`:ConstIterator^ V`::ConstIterator]_ConstIterator&]
[s2; Constant iterator type.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:Begin`(`)const:%- [_^`:`:AIndex`:`:ConstIterator^ ConstIterator]_[* Be
gin]()_[@(0.0.255) const]&]
[s2; Returns a constant iterator to the first element in AIndex.&]
[s7; [*/ Return value]-|Iterator.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:End`(`)const:%- [_^`:`:AIndex`:`:ConstIterator^ ConstIterator]_[* End](
)_[@(0.0.255) const]&]
[s2; Returns a constant iterator to the position just beyond the
last element in AIndex.&]
[s7; [*/ Return value]-|Iterator.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:GetIter`(int`)const:%- [_^`:`:AIndex`:`:ConstIterator^ ConstIterator
]_[* GetIter]([@(0.0.255) int]_[*@3 pos])_[@(0.0.255) const]&]
[s2; Returns a constant iterator to the element at specified position.
Same as [* Begin() `+ i]. The benefit of this method is that [* pos]
is range checked in debug mode.&]
[s7; [*C@3 pos]-|Required position.&]
[s7; [*/ Return value]-|Iterator.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:AIndex`(`):%- [* AIndex]()&]
[s2; Constructor. Constructs an empty AIndex.&]
[s3;%- &]
[s4;%- &]
[s5;:`:`:AIndex`:`:AIndex`(const`:`:AIndex`&`,int`):%- [* AIndex]([@(0.0.255) const]_[* AIn
dex]`&_[*@3 s], [@(0.0.255) int])&]
[s2; Optional deep copy constructor.&]
[s6; Requires T to have deep copy constructor or optional deep copy
constructor.&]
[s7; [*C s]-|Source AIndex.&]
[s0; ] [s0; ]

View file

@ -0,0 +1,26 @@
topic "GUI Tutorial";
[2 $$0,0#00000000000000000000000000000000:Default]
[l288;i1120;a17;O9;~~~.1408;2 $$1,0#10431211400427159095818037425705:param]
[a83;*R6 $$2,5#31310162474203024125188417583966:caption]
[H4;b83;*4 $$3,5#07864147445237544204411237157677:title]
[i288;O9;C2 $$4,6#40027414424643823182269349404212:item]
[b42;a42;2 $$5,5#45413000475342174754091244180557:text]
[l288;b17;a17;2 $$6,6#27521748481378242620020725143825:desc]
[l321;tC@5;1 $$7,7#20902679421464641399138805415013:code]
[b2503;2 $$8,0#65142375456100023862071332075487:separator]
[*@(0.0.255)2 $$9,0#83433469410354161042741608181528:base]
[tC2 $$10,0#37138531426314131251341829483380:class]
[l288;a17;*1 $$11,11#70004532496200323422659154056402:requirement]
[i417;b42;a42;O9;~~~.416;2 $$12,12#10566046415157235020018451313112:tparam]
[b167;C2 $$13,13#92430459443460461911108080531343:item1]
[i288;a42;O9;C2 $$14,14#77422149456609303542238260500223:item2]
[*@2$(0.128.128)2 $$15,15#34511555403152284025741354420178:NewsDate]
[l321;*C$7;2 $$16,16#03451589433145915344929335295360:result]
[l321;b83;a83;*C$7;2 $$17,17#07531550463529505371228428965313:result`-line]
[l160;*tC+117 $$18,5#88603949442205825958800053222425:package`-title]
[2 $$19,0#53580023442335529039900623488521:gap]
[tC2 $$20,20#70211524482531209251820423858195:class`-nested]
[b50;2 $$21,21#03324558446220344731010354752573:Par]
[{_}%EN-US
[s2; Tutorial&]
[s3; ]

View file

@ -1,28 +1,499 @@
TITLE("NTL Tutorial") topic "NTL Tutorial";
COMPRESSED [2 $$0,0#00000000000000000000000000000000:Default]
120,156,189,91,9,115,219,70,150,254,43,189,118,38,67,57,52,141,147,167,38,51,182,114,76,118,19,219,21,59,51,181,165,98,66,144,132,72,172,64,128,6,64,201,218,28,191,125,191,247,250,64,3,4,37,59,153,29,167,34,81,64,191,215,239,190,186,121,233,137,79,62,113,250,206,99,231,129,127,211,47,226,171,232,144,86,243,203,212,27,143,103,201,200,9,102,145,59,154,189,154,204,126,251,237,183,193,100,226,205,8,149,11,84,174,19,248,174,231,186,129,227,4,222,200,13,39,206,36,28,187,99,199,31,5,94,56,114,194,233,62,42,162,221,252,50,26,251,179,39,223,15,1,229,245,195,199,190,235,187,142,59,244,2,172,114,124,199,11,92,47,116,199,227,192,29,133,99,127,50,28,78,87,209,190,74,242,108,126,185,36,56,218,204,7,152,51,26,15,3,23,64,65,232,249,163,48,0,112,16,184,46,62,187,225,104,56,26,77,171,164,74,99,0,185,195,209,44,10,188,217,5,65,6,253,225,99,144,231,141,0,26,120,193,48,240,199,158,239,142,61,111,56,241,131,73, [l288;i1120;a17;O9;~~~.1408;2 $$1,0#10431211400427159095818037425705:param]
0,186,93,111,154,84,49,168,92,2,134,224,8,44,196,134,65,24,184,62,4,18,140,66,31,203,70,248,29,56,19,215,195,174,99,39,12,177,97,252,94,75,137,4,68,112,67,108,231,141,66,90,61,14,198,174,63,26,123,129,55,244,64,128,51,2,151,180,123,56,93,199,229,10,112,190,231,206,42,144,52,187,248,91,56,115,1,60,234,143,30,123,206,196,241,134,163,9,54,4,177,96,216,159,76,92,127,140,13,3,55,116,92,127,186,202,215,196,164,23,58,62,239,56,134,30,134,192,204,50,9,135,46,8,246,252,49,182,28,185,190,143,159,97,48,30,77,203,152,52,81,229,197,252,242,201,223,122,206,192,25,120,97,120,70,224,19,128,143,253,192,247,131,225,36,112,29,31,219,0,71,64,242,26,58,208,165,27,122,227,233,50,42,177,103,21,144,100,89,170,46,25,18,4,239,143,67,31,91,15,241,3,74,5,131,62,100,227,77,130,177,239,143,157,233,42,141,202,210,18,208,19,98,210,117,251,174,251,120,68,114,13,125,47,152,144,112,124,15,2,246,134,225,196,133,132, [a83;*R6 $$2,5#31310162474203024125188417583966:caption]
195,97,224,120,211,34,126,119,72,138,120,23,103,16,113,2,219,152,105,245,40,59,4,49,210,14,189,190,235,193,18,195,225,208,33,121,133,176,6,207,15,33,112,199,29,7,160,8,255,65,197,149,50,197,101,205,131,223,119,253,199,19,47,240,65,201,36,8,32,1,32,112,39,174,235,58,99,252,7,206,32,23,182,13,23,36,48,19,114,123,9,30,244,221,224,241,8,54,12,77,77,2,218,126,226,147,252,60,136,223,27,58,33,244,224,73,112,143,164,238,125,2,185,187,222,152,254,103,201,187,97,223,133,51,128,68,55,12,193,183,15,81,123,99,240,30,66,246,62,219,183,59,26,79,95,198,183,229,23,81,21,43,131,121,114,241,137,180,52,119,216,119,135,143,29,130,15,199,19,40,208,13,72,126,126,16,76,188,137,239,135,222,36,244,135,14,228,88,74,95,38,96,242,39,246,69,131,100,212,119,71,240,44,240,26,134,224,158,193,192,249,200,37,82,188,241,100,72,82,80,72,22,79,211,36,35,58,96,25,51,105,12,79,46,62,115,221,17,33,26,195,97,198,227,161,227, [H4;b83;*4 $$3,5#07864147445237544204411237157677:title]
79,32,12,200,192,9,97,233,136,6,99,40,26,122,246,224,6,20,14,86,215,209,38,94,60,85,174,250,243,79,191,254,233,203,151,79,127,120,35,46,75,111,38,94,190,253,86,188,61,192,74,147,40,253,116,126,89,250,51,225,14,196,63,226,21,30,9,216,96,178,42,233,113,56,19,223,198,149,56,148,162,172,162,162,18,183,73,181,21,145,40,147,221,62,141,197,229,19,5,49,23,249,149,72,178,138,97,70,51,241,244,23,243,234,28,143,63,159,139,155,153,66,247,223,249,65,172,162,76,68,235,181,136,83,54,186,82,84,185,168,182,177,222,62,42,5,91,80,92,197,69,73,152,233,29,16,62,95,175,231,2,79,183,249,218,236,115,51,80,47,122,238,217,204,122,138,71,61,239,232,137,127,166,201,120,155,11,152,11,252,212,236,122,167,8,59,148,49,88,89,39,171,184,230,230,42,47,122,224,67,36,98,241,23,225,204,240,251,92,240,206,95,199,213,69,126,128,223,244,206,240,116,241,217,226,179,51,3,244,244,151,111,95,125,221,187,193,170,197,229,60,161,95,243,185,220, [i288;O9;C2 $$4,6#40027414424643823182269349404212:item]
31,238,36,132,107,62,121,230,147,175,168,123,158,130,182,44,170,146,155,184,47,126,32,180,34,74,203,92,236,139,252,38,65,72,83,180,231,69,147,68,75,226,139,233,20,59,126,163,150,205,197,59,162,156,73,126,17,111,146,12,244,246,69,108,158,125,153,173,153,131,119,226,63,240,40,198,135,46,86,136,133,39,243,119,31,200,195,54,191,141,111,226,130,149,71,50,37,11,209,84,139,164,196,179,67,148,166,119,2,6,31,23,55,241,90,128,3,81,238,227,21,44,82,228,251,125,94,84,135,44,169,18,226,54,83,66,232,165,201,53,180,67,198,71,134,147,100,27,200,101,3,35,174,182,59,65,209,250,76,68,217,90,108,226,12,27,17,242,117,188,47,226,21,180,188,30,136,127,198,162,60,108,54,113,89,177,174,97,115,150,170,197,33,75,227,178,228,55,219,232,38,134,145,23,49,163,216,228,249,154,62,151,121,70,48,235,92,228,96,169,184,77,202,120,32,89,125,38,94,230,85,60,21,144,17,49,182,78,162,77,150,151,21,92,72,236,162,85,65,182,29,85,34,63,84,251, [b42;a42;2 $$5,5#45413000475342174754091244180557:text]
67,69,170,43,69,84,108,14,196,128,54,252,65,154,111,196,85,146,18,57,160,121,121,216,136,29,184,25,136,231,25,111,70,14,151,164,81,33,241,149,226,54,134,39,166,169,98,0,40,176,109,165,188,25,200,99,241,197,15,223,189,22,61,13,165,118,1,125,125,177,60,84,98,125,216,237,75,126,84,230,135,98,21,139,248,61,196,84,150,9,179,152,75,33,18,138,11,209,171,215,174,242,172,34,154,149,67,210,159,17,130,84,113,54,80,1,196,51,1,36,223,147,162,129,174,108,121,61,217,100,6,125,87,136,24,5,253,245,125,188,203,111,226,121,29,10,32,169,2,219,231,59,177,207,203,132,113,208,142,18,177,49,72,203,210,85,104,177,188,252,254,72,208,12,29,138,154,158,219,23,174,163,44,27,111,197,13,249,198,226,103,193,207,251,194,19,139,95,155,128,138,240,94,39,144,5,1,230,41,66,85,58,114,193,148,170,67,1,166,20,199,196,48,91,253,85,2,31,208,60,139,56,43,15,5,217,55,219,78,121,88,81,216,173,223,190,79,202,170,28,136,111,88,21,208,55, [l288;b17;a17;2 $$6,6#27521748481378242620020725143825:desc]
244,15,75,1,84,126,216,108,107,97,194,54,164,164,250,66,37,249,181,200,14,187,37,44,10,50,173,151,149,20,142,201,71,128,176,140,161,217,117,29,129,105,229,243,138,214,144,141,96,125,95,100,241,45,28,131,65,44,197,17,25,228,176,81,154,252,47,94,176,209,1,234,38,74,15,100,201,88,65,132,71,228,188,125,99,193,43,120,22,98,240,26,252,20,9,108,147,184,195,134,223,179,9,252,131,64,101,206,57,100,215,89,126,155,193,1,222,39,59,24,57,99,85,26,177,20,115,145,198,81,209,179,180,221,21,185,169,110,115,58,194,181,204,37,48,6,107,119,138,147,206,25,173,60,86,51,82,110,95,76,38,244,99,236,147,157,160,62,162,159,252,57,116,232,241,68,45,192,150,35,250,88,91,197,19,50,11,147,12,247,123,18,168,14,101,176,248,172,246,175,18,145,122,176,25,136,249,27,132,68,59,193,210,223,243,222,77,135,1,74,202,136,40,69,130,167,9,173,137,105,147,171,40,131,31,251,3,241,22,62,88,94,65,249,73,89,30,98,237,197,175,174,16,0,56,68, [l321;tC@5;1 $$7,7#20902679421464641399138805415013:code]
102,177,212,240,30,85,167,29,24,242,204,10,12,180,32,82,1,76,5,141,18,54,37,170,187,61,12,130,42,144,154,71,68,255,52,205,111,197,229,143,85,190,79,86,139,233,226,217,226,217,69,94,196,139,103,101,177,90,231,171,197,51,60,190,94,252,180,248,36,206,22,79,15,229,143,136,147,220,59,9,122,14,171,221,69,25,133,220,121,95,186,204,46,6,7,202,123,100,144,171,233,162,32,141,52,80,228,119,241,250,143,135,148,110,12,46,233,119,241,23,171,242,129,253,106,82,84,152,188,188,16,55,243,6,53,98,241,148,249,145,159,40,12,235,178,36,203,69,154,103,27,80,31,173,86,148,169,40,143,40,201,67,95,91,246,225,93,82,33,213,193,148,128,46,194,98,177,140,145,204,18,108,138,164,70,217,40,35,183,189,129,164,80,26,34,126,124,149,20,37,252,57,97,247,6,178,18,110,8,124,64,112,21,33,77,210,254,8,33,59,36,51,208,80,198,176,196,74,27,6,20,202,62,136,5,128,137,214,244,224,234,64,30,157,239,239,8,29,92,125,69,152,110,73,5,218, [b2503;2 $$8,0#65142375456100023862071332075487:separator]
102,6,226,13,135,151,126,91,253,196,98,9,153,196,86,81,72,128,41,202,88,137,210,228,20,146,12,39,189,72,82,213,151,22,80,213,38,203,166,150,103,41,1,49,4,248,190,141,238,84,186,254,112,11,187,252,241,71,138,136,68,188,42,6,140,221,171,170,69,201,0,188,43,205,246,72,102,134,133,242,192,117,12,244,27,239,91,92,32,174,216,21,231,92,82,138,200,214,94,75,233,180,96,229,84,197,161,145,4,111,200,196,206,207,217,200,92,109,101,47,97,101,75,248,156,45,92,46,104,140,251,25,163,185,168,113,82,241,181,99,54,104,69,45,106,46,103,74,42,180,14,73,185,5,239,203,59,33,139,247,68,145,75,193,213,228,138,110,87,240,184,8,70,28,85,229,47,66,76,128,221,211,132,43,32,4,3,29,95,222,228,176,187,130,115,3,37,181,67,73,9,144,54,128,237,210,58,59,105,33,87,33,83,20,107,25,102,164,233,172,36,74,4,6,240,189,150,168,9,190,209,93,176,134,172,191,187,35,206,226,217,43,20,175,55,73,124,91,155,195,85,26,221,160,150,62, [*@(0.0.255)2 $$9,0#83433469410354161042741608181528:base]
99,104,166,103,119,128,103,148,16,85,121,117,119,18,209,119,168,19,162,101,26,215,136,118,234,201,92,88,173,183,50,235,114,11,131,97,151,100,228,148,213,149,38,209,150,193,60,159,238,115,112,68,90,205,64,252,77,130,42,25,90,144,181,5,132,242,214,144,181,196,239,168,160,72,66,158,175,118,164,29,140,208,164,156,4,163,187,138,84,132,44,224,181,82,242,70,153,210,72,196,23,118,142,158,146,237,105,206,230,231,246,187,207,145,129,172,172,250,166,226,58,134,255,209,20,103,102,189,179,205,100,29,85,81,253,110,241,171,109,208,148,72,208,47,54,40,48,78,166,220,136,36,69,158,132,224,44,75,6,99,149,40,122,209,3,112,173,92,105,137,151,141,230,147,29,68,231,19,114,192,197,83,246,64,203,235,116,60,110,208,176,206,99,89,120,49,2,36,191,62,9,219,230,138,194,174,157,168,8,177,193,217,71,212,104,34,68,80,143,211,43,134,58,90,13,139,71,3,158,31,210,53,37,131,37,181,40,220,155,160,33,140,68,156,80,154,173,57,181,152,144,32,73,118,147,167, [tC2 $$10,0#37138531426314131251341829483380:class]
32,146,106,125,20,151,232,44,57,200,144,106,184,119,167,188,40,9,87,97,146,74,99,10,236,125,211,122,147,84,209,197,216,205,57,17,90,49,49,216,148,115,86,82,25,126,13,237,165,232,113,180,166,36,179,141,163,253,153,41,126,77,129,202,178,213,165,113,17,35,142,199,25,44,178,162,54,189,29,85,154,198,70,241,233,184,222,203,168,18,162,164,43,16,31,81,223,224,19,151,123,77,219,180,49,45,62,21,107,2,34,124,102,168,112,102,91,235,122,64,246,139,136,43,22,143,222,82,27,185,120,68,127,100,246,154,143,169,55,9,35,89,253,224,121,213,163,158,167,119,38,254,36,178,70,189,169,124,193,170,52,184,199,230,221,195,41,149,122,158,227,82,73,199,37,158,231,120,33,125,30,243,147,209,72,149,116,53,200,144,65,220,225,8,197,169,59,28,83,253,55,28,210,226,97,200,63,131,33,253,28,13,143,0,71,18,48,8,2,44,8,28,90,22,184,19,250,57,161,242,209,103,132,1,83,18,152,82,178,6,31,75,112,207,39,64,208,138,159,94,64,164,122,35,159,127, [l288;a17;*1 $$11,11#70004532496200323422659154056402:requirement]
210,19,223,33,122,60,42,156,93,207,61,166,97,34,145,184,46,1,226,31,253,116,104,177,235,121,140,150,127,50,18,135,170,94,215,25,6,252,36,60,66,229,58,140,107,50,164,226,56,28,114,73,204,112,30,23,195,196,223,100,18,48,10,126,73,27,76,60,198,233,251,117,99,167,187,115,244,101,101,178,76,210,164,226,202,71,77,22,96,64,175,169,48,145,177,25,45,207,54,65,23,135,55,29,190,109,87,81,221,241,103,32,190,164,38,160,59,4,238,146,205,150,35,190,156,124,84,50,81,151,57,114,249,213,33,91,241,98,99,78,13,20,23,220,127,209,35,233,54,102,64,70,254,72,19,21,30,203,80,190,71,160,224,54,212,142,155,202,119,33,132,12,213,105,126,93,10,26,208,52,156,241,148,35,218,126,85,123,28,9,108,222,179,136,202,206,106,138,234,161,88,122,215,172,158,84,196,177,68,10,9,220,68,69,18,241,140,37,111,111,70,5,252,25,17,102,237,116,54,19,207,158,217,155,168,82,37,68,239,90,20,209,157,74,255,58,56,90,237,243,58,231,28,160,235,0, [i417;b42;a42;O9;~~~.416;2 $$12,12#10566046415157235020018451313112:tparam]
43,167,151,44,61,37,37,9,79,237,73,124,167,234,93,234,128,161,53,174,94,184,212,182,119,170,167,63,106,250,68,184,100,77,36,151,81,211,31,171,193,153,14,153,244,214,16,134,112,108,35,196,106,26,200,33,19,160,69,71,224,137,173,72,91,82,145,105,74,11,89,49,237,116,38,248,82,118,237,141,153,129,42,191,57,237,54,88,104,112,203,83,129,55,205,82,191,71,127,155,204,41,103,31,119,92,83,81,79,160,224,136,167,124,73,173,75,169,216,47,207,166,118,243,203,140,205,207,177,241,122,49,157,166,208,160,76,184,159,67,133,247,183,255,129,14,197,205,92,208,66,132,116,144,18,80,148,74,107,233,10,242,239,20,214,119,192,154,116,12,77,159,254,146,14,246,135,114,187,248,137,74,183,222,187,179,118,76,135,121,13,7,226,117,158,222,237,242,98,143,248,32,217,210,225,133,117,71,150,2,189,101,38,201,242,156,148,102,125,80,245,222,2,53,170,105,23,110,47,229,196,167,193,173,46,28,215,249,129,202,194,175,99,56,128,12,55,146,167,118,111,107,234,184,183,185, [b167;C2 $$13,13#92430459443460461911108080531343:item1]
252,80,47,255,89,229,109,241,188,84,175,24,27,252,201,154,153,169,122,206,70,169,168,251,6,38,71,109,237,84,236,65,10,248,232,34,151,99,211,236,3,233,55,4,101,13,18,44,104,181,167,10,121,216,58,67,160,1,224,7,17,252,133,220,242,94,122,21,89,255,66,146,229,174,61,141,248,94,162,185,120,147,211,55,217,32,55,134,116,114,110,167,2,137,41,150,165,235,115,49,7,16,83,160,113,155,99,10,62,228,31,25,235,150,220,44,92,177,61,46,169,45,190,229,132,161,176,244,149,233,86,209,53,5,150,91,114,251,109,178,167,248,65,3,35,192,228,203,255,65,152,96,24,57,163,136,101,234,176,134,52,88,204,148,48,5,154,1,195,41,111,112,46,69,255,57,205,52,107,73,227,15,83,191,225,55,104,155,107,35,235,249,103,103,205,133,228,219,68,189,18,175,27,14,194,7,150,120,3,239,36,22,189,141,247,224,2,231,129,93,22,79,189,129,239,235,141,120,184,135,85,106,188,71,69,10,8,69,193,55,160,130,133,43,191,190,80,32,117,121,242,118,27,101,215,28, [i288;a42;O9;C2 $$14,14#77422149456609303542238260500223:item2]
204,111,227,52,53,109,113,125,98,98,103,170,58,161,242,176,113,141,231,60,190,145,163,73,26,53,210,80,146,43,0,19,163,152,248,101,158,167,102,84,113,222,147,6,45,21,131,24,26,245,69,235,201,178,142,144,13,151,81,14,16,13,164,99,156,139,165,252,116,162,14,198,175,129,252,215,118,83,162,181,7,97,117,138,78,9,73,10,141,165,87,11,211,26,129,142,6,226,69,34,101,32,199,28,117,254,82,194,181,218,22,21,167,235,12,23,241,40,83,142,208,100,229,36,187,27,116,225,141,252,140,12,74,105,47,206,184,238,43,161,13,74,197,3,72,27,222,150,236,104,222,198,243,24,149,232,73,119,228,122,155,36,179,215,83,129,35,122,250,56,141,134,33,106,234,244,213,55,95,189,146,94,85,159,199,156,241,220,132,213,40,67,195,139,196,226,228,69,34,121,41,183,220,51,170,140,99,36,171,215,202,76,107,5,183,76,57,220,223,81,194,54,79,98,245,155,183,81,146,206,27,231,48,217,64,1,232,83,217,250,41,45,238,5,182,254,44,195,103,213,5,118,148,228,61,190, [*@2$(0.128.128)2 $$15,15#34511555403152284025741354420178:NewsDate]
40,242,189,220,190,3,238,62,32,73,217,9,32,27,66,9,231,116,208,209,252,216,142,222,21,42,152,189,135,131,142,193,117,127,224,49,216,238,11,62,71,116,117,6,160,54,97,247,6,33,10,57,109,15,106,7,33,120,210,152,12,110,29,191,55,121,9,159,249,192,201,10,245,168,74,239,68,235,176,114,159,70,117,49,217,147,19,106,117,48,168,6,224,17,155,170,93,147,114,38,51,110,39,39,191,198,197,206,228,107,58,161,56,100,9,92,71,92,161,246,63,32,33,202,169,5,209,68,169,181,202,37,10,196,163,34,65,225,85,159,186,213,91,73,84,230,72,77,14,129,101,70,133,85,125,149,100,199,23,21,248,172,17,188,207,207,101,145,4,251,89,191,183,52,176,126,111,146,214,226,81,148,94,69,139,71,103,205,215,148,33,22,143,150,113,117,234,213,38,218,237,78,189,91,199,233,73,184,107,196,120,243,78,106,121,253,94,105,153,40,161,169,82,133,159,140,191,47,24,85,95,48,148,237,31,116,96,220,83,124,176,8,106,106,155,168,7,244,182,126,73,59,185,71,109,149, [l321;*C$7;2 $$16,16#03451589433145915344929335295360:result]
62,210,84,135,142,212,89,176,252,250,140,219,140,138,34,68,198,13,183,107,141,35,65,139,26,181,25,53,195,168,136,178,205,73,114,236,21,204,253,83,77,213,243,236,206,144,69,25,18,113,177,136,97,160,43,83,71,209,105,92,92,29,41,93,73,131,94,245,40,67,55,213,208,18,181,146,235,67,178,150,82,146,199,190,84,206,237,26,135,38,108,152,102,212,207,34,177,58,206,101,172,111,189,172,155,230,250,146,174,215,181,169,167,234,248,138,59,39,75,74,199,134,116,187,77,16,43,176,240,115,234,28,218,19,54,82,195,85,210,108,159,12,78,123,247,230,42,203,174,86,52,115,164,161,219,159,179,197,159,107,193,57,194,151,5,178,60,97,39,60,214,5,33,227,190,101,167,255,114,86,36,16,121,33,34,249,0,179,83,33,130,138,231,147,38,175,220,23,49,198,88,217,177,49,74,167,171,110,243,135,215,108,139,248,223,137,169,69,183,153,153,117,173,226,177,206,137,21,146,34,90,49,60,181,66,209,67,107,70,255,175,88,90,212,194,88,190,63,170,195,174,10,100,149,102,114, [l321;b83;a83;*C$7;2 $$17,17#07531550463529505371228428965313:result`-line]
49,197,21,233,60,189,141,238,202,122,112,174,78,152,241,230,118,123,7,56,158,209,224,81,38,75,60,188,151,89,78,213,97,37,153,231,15,89,154,100,215,115,174,178,204,159,255,5,183,156,215,181,153,30,17,166,49,157,38,88,35,114,137,142,12,117,23,93,243,41,70,146,221,36,101,66,233,138,166,1,28,17,13,158,118,244,81,91,55,139,47,251,21,200,152,183,211,128,93,80,55,67,41,62,44,46,189,197,252,164,45,89,168,78,155,82,141,198,10,181,205,21,53,154,102,52,214,151,38,42,154,228,222,110,99,22,191,117,155,102,147,208,180,196,120,125,194,119,187,192,166,29,243,190,41,127,80,207,142,162,158,237,211,214,50,84,181,93,12,215,43,236,186,171,193,140,181,196,101,86,156,83,175,189,70,46,212,143,173,139,80,38,249,232,198,27,52,190,62,156,204,59,244,10,98,188,202,243,15,73,57,88,214,76,56,125,121,162,5,63,36,139,135,171,117,102,123,165,43,185,73,119,102,149,239,104,79,175,165,67,190,213,40,189,134,186,166,90,83,77,223,148,14,80,167,218, [l160;*tC+117 $$18,5#88603949442205825958800053222425:package`-title]
219,56,222,119,50,205,111,122,31,199,107,55,147,148,246,249,162,93,25,37,200,18,181,151,214,173,177,105,232,228,252,62,46,170,70,84,65,186,145,116,83,150,230,18,215,138,32,228,204,165,110,243,228,168,70,14,241,41,249,236,162,138,167,40,101,46,83,55,79,109,110,80,156,171,2,53,111,43,90,95,70,115,239,227,252,97,158,143,81,170,208,32,67,241,71,225,62,129,86,223,183,227,106,72,10,237,4,102,249,178,255,65,59,64,89,48,53,234,127,249,180,146,78,17,64,121,57,183,110,50,112,79,94,234,155,159,249,178,178,218,11,187,135,48,90,75,232,72,227,86,78,47,248,24,33,105,220,140,232,113,217,163,111,238,240,233,136,188,1,194,208,245,140,67,117,204,186,232,95,91,165,143,33,211,30,114,240,244,98,109,73,100,221,148,180,45,14,45,162,35,121,160,239,154,12,180,245,209,65,206,241,93,139,227,219,19,246,193,142,170,121,216,250,204,109,2,125,135,160,103,31,189,232,81,188,108,110,56,29,201,123,23,156,35,201,114,97,209,242,70,105,141,77,159,183,203, [2 $$19,0#53580023442335529039900623488521:gap]
107,26,219,216,204,143,22,127,161,145,59,214,70,245,193,21,200,89,229,187,253,161,138,233,184,121,171,47,20,190,204,171,100,69,93,87,180,225,147,9,16,114,145,239,150,64,249,119,172,154,43,48,250,219,2,147,215,201,153,190,40,45,208,20,223,9,121,175,16,171,229,21,99,190,46,114,69,198,36,228,85,252,246,248,247,117,92,148,124,1,66,223,126,56,151,79,186,175,61,100,40,195,103,199,143,75,52,47,141,55,214,18,137,174,103,33,232,139,38,152,125,198,48,229,21,61,126,220,215,11,122,122,97,115,60,108,112,63,60,235,62,32,78,109,72,59,242,146,59,137,148,239,67,206,213,128,79,34,90,124,42,246,247,143,243,90,90,233,237,7,146,161,253,64,147,120,122,190,215,154,45,146,109,180,119,55,227,69,243,228,193,241,34,109,42,216,206,150,234,243,167,132,72,211,163,95,29,105,232,3,167,143,236,7,198,36,246,53,252,158,187,109,165,128,197,163,255,204,183,217,226,17,69,193,55,59,244,108,205,218,188,181,246,117,116,72,229,218,139,168,64,10,65,114,184,119, [tC2 $$20,20#70211524482531209251820423858195:class`-nested]
61,86,169,245,95,102,155,52,46,155,139,229,85,156,102,34,223,203,84,253,208,142,86,88,250,64,136,86,115,207,195,252,174,83,67,25,171,40,145,94,217,135,146,240,197,198,217,133,30,185,244,219,113,71,85,70,141,113,165,177,97,219,128,219,3,234,236,126,123,105,128,102,3,117,178,245,59,76,246,143,79,196,149,97,254,190,161,120,83,92,245,12,179,53,121,109,204,8,93,167,57,36,60,58,44,113,90,115,203,142,99,142,251,49,120,53,134,230,232,149,239,117,56,114,42,79,115,70,124,60,46,62,165,5,54,136,177,113,117,188,54,214,72,95,119,114,244,215,21,190,139,246,202,66,205,223,106,12,64,211,32,57,96,225,246,206,124,241,137,242,145,53,85,168,19,173,186,65,101,234,91,157,33,235,193,4,219,52,146,153,125,73,191,113,65,81,81,163,181,102,30,234,193,97,95,232,224,178,235,72,31,59,107,138,232,146,63,126,88,192,217,169,81,160,215,0,185,47,142,24,208,58,19,144,116,237,253,253,198,152,104,175,35,175,208,193,194,126,87,71,223,102,4,153,29,105, [b50;2 $$21,21#03324558446220344731010354752573:Par]
198,124,7,202,84,102,170,101,231,187,98,212,236,161,170,73,185,34,107,235,165,105,63,59,245,5,46,85,130,181,187,59,253,154,93,191,177,64,183,111,187,129,130,150,119,73,204,57,131,111,221,55,226,53,18,133,89,69,154,16,172,132,190,32,17,11,41,93,8,30,98,17,134,121,209,112,109,171,105,178,191,182,84,213,223,99,219,69,123,125,183,247,254,111,174,49,77,252,181,181,147,223,90,179,100,51,239,37,103,242,206,219,84,93,120,219,117,124,165,205,18,139,59,181,56,212,15,189,169,205,170,126,234,79,91,60,159,102,184,53,87,39,198,63,98,66,127,29,223,117,104,87,79,169,189,70,231,186,211,109,171,215,26,78,203,111,44,125,93,207,121,27,68,172,242,2,5,227,62,207,248,192,175,99,24,173,101,218,181,35,5,245,122,195,150,164,176,245,235,168,228,230,23,124,180,199,147,181,103,68,37,161,183,190,185,195,199,44,105,190,161,203,33,69,65,119,143,168,237,148,163,99,249,21,34,234,1,45,0,116,169,242,75,96,84,187,235,17,251,209,23,130,144,162,137,14, [{_}%EN-US
53,41,181,73,104,51,44,217,242,253,70,84,81,95,229,145,129,101,47,163,71,163,182,248,56,56,18,152,254,118,144,124,106,181,239,100,4,170,151,105,53,45,122,32,7,21,242,80,205,10,199,167,71,107,165,21,48,37,130,198,97,167,226,218,50,159,123,172,234,120,160,165,40,123,35,221,206,178,177,213,150,191,204,65,57,130,4,175,190,75,163,40,110,134,126,5,76,223,103,147,2,60,38,239,223,165,148,99,43,254,224,115,11,54,47,203,174,106,237,233,96,71,215,211,62,224,8,67,231,181,22,213,175,99,78,46,125,78,69,89,215,160,178,51,182,251,242,176,211,255,23,5,120,34,136,252,9,36,136,227,66,210,92,48,51,150,211,82,167,60,119,121,215,121,236,162,207,76,118,139,203,119,139,121,243,244,68,45,121,103,210,117,125,4,115,124,67,205,84,23,196,107,71,4,55,28,116,71,110,158,84,214,83,189,122,146,105,84,215,53,190,220,29,205,166,91,172,239,172,233,166,215,172,89,158,167,137,84,236,139,104,25,181,139,28,128,96,73,16,52,32,190,185,137,148,253, [s2; U`+`+ Containers Tutorial&]
254,51,73,175,143,138,156,211,153,222,99,107,8,130,143,176,6,80,39,136,176,99,83,32,42,4,19,112,148,247,101,218,160,193,208,43,154,216,204,27,55,120,100,140,150,163,28,123,142,213,250,30,130,57,108,111,214,166,9,127,5,89,66,91,95,227,171,115,138,190,243,31,173,42,121,191,68,141,60,169,210,58,186,148,213,121,21,232,143,244,234,221,61,185,248,171,110,227,207,85,15,223,234,109,79,253,155,90,40,207,255,64,143,111,11,86,202,14,228,181,181,212,107,216,66,29,72,13,128,169,23,157,186,100,60,89,179,49,212,253,117,155,241,121,101,172,61,134,89,92,38,116,200,210,44,224,22,151,245,187,142,240,96,138,54,84,109,218,98,239,45,217,78,150,125,65,48,181,44,187,59,70,108,80,179,212,131,88,61,166,43,40,9,216,113,34,89,93,171,82,156,6,115,251,65,115,208,171,155,171,174,169,45,159,171,53,103,181,150,173,55,190,146,105,215,48,74,203,102,148,83,154,128,105,209,98,157,53,200,5,191,223,225,173,9,73,45,135,250,158,244,3,183,203,235,1, [s3; 1. Vector basics&]
246,67,51,20,121,149,236,168,32,226,241,0,245,153,250,187,8,71,179,131,70,19,170,39,8,145,213,133,70,58,221,62,167,120,218,24,37,216,113,216,44,123,161,151,153,27,78,206,113,236,141,142,131,239,243,190,120,97,5,221,168,43,234,54,111,111,53,107,160,72,23,51,207,59,142,196,35,147,111,95,116,165,130,6,172,233,14,212,27,11,176,241,138,126,195,145,231,255,7,17,77,156,51, [s5; Let us start with a simple [* Vector] of ints&]
[s7; -|[* Vector<int>] v;&]
[s5; You can add elements to the Vector as parameters of the [* Add]
method&]
[s7; -|v.[* Add](1);&]
[s7; -|v.Add(2);&]
[s7; -|v.Add(3);&]
[s5; To iterate Vector you can use indices&]
[s7; -|for(int i `= 0; i < v.[* GetCount](); i`+`+)&]
[s7; -|-|LOG(v[* `[]i[* `]]);&]
[s16; 1&]
[s16; 2&]
[s16; 3&]
[s5; Alternative, U`+`+ also provides iterators&]
[s7; -|for(Vector<int>`::[* Iterator] q `= v.[* Begin](), e `= v.[* End]();
q !`= e; q`+`+)&]
[s7; -|-|LOG([* `*]q);&]
[s16; 1&]
[s16; 2&]
[s16; 3&]
[s5; however the use of iterators is usually reserved for special
opportunities in U`+`+ (like implementing algorithm code) and
generally deprecated. We suggest you to use indices unless you
have a really good reason to do otherwise.&]
[s5; [/ Note: LOG is diagnostics macro that outputs its argument to
the .log file in debug mode. Another similar macros we will use
in this tutorial are DUMP (similar to the LOG, but dumps the
source expression too) and DUMPC (dumps the content of the container).]&]
[s5;/ &]
[s3; 2. Vector operations&]
[s5; You can [* Insert] or [* Remove] elements at random positions of
Vector&]
[s7; -|Vector<int> v;&]
[s7; -|v.Add(1);&]
[s7; -|v.Add(2);&]
[s7; -|&]
[s7; -|v.[* Insert](1, 10);&]
[s17; v `= `{ 1, 10, 2 `}&]
[s7; -|v.[* Remove](0);&]
[s17; v `= `{ 10, 2 `}&]
[s5; [* At] method returns element at specified position ensuring that
such a position exists. If there is not enough elements in Vector,
required number of elements is added. If second parameter of
At is present, newly added elements are initialized to this value.
As an example, we will create distribution of RandomValue with
unknown maximal value&]
[s7; &]
[s7; -|v.Clear();&]
[s7; -|for(int i `= 0; i < 10000; i`+`+)&]
[s7; -|-|v.[* At](RandomValue(), 0)`+`+;&]
[s17; v `= `{ 958, 998, 983, 1012, 1013, 1050, 989, 998, 1007, 992
`}&]
[s5; You can apply algorithms on containers, e.g. [* Sort]&]
[s7; -|[* Sort](v);&]
[s17; v `= `{ 958, 983, 989, 992, 998, 998, 1007, 1012, 1013, 1050
`}&]
[s0; &]
[s3; 3. Transfer issues&]
[s5; Often you need to pass content of one container to another of
the same type. NTL containers follow [^topic`:`/`/Core`/srcdoc`/pick`_`$en`-us^ def
ault pick semantics], that means that source container is destroyed&]
[s7; -|Vector<int> v;&]
[s7; -|v.Add(1);&]
[s7; -|v.Add(2);&]
[s7; &]
[s7; -|Vector<int> v1 [* `=] v;&]
[s5; now source Vector [C v] is destroyed `- picked `- and you can
no longer access its content. This admittedly strange behaviour
has many advantages. First, it is consistently fast and in most
cases, transfer of value instead of full copy is exactly what
you need. Second, NTL containers can store elements that lack
copy operation `- in that case, pick transfer is the only option
anyway.&]
[s5; If you really need to preserve value of source (and elements
support deep copy operation), you can use [^topic`:`/`/Core`/srcdoc`/pick`_`$en`-us^ o
ptional deep copy operator or constructor]&]
[s7; -|v [* <<`=] v1;&]
[s5; Now both containers have the same content. Constructor form
of same operation is distinguished by an additional int parameter&]
[s7; -|Vector<int> v2(v[* , 0]);&]
[s7; &]
[s3; 4. Client types&]
[s5; So far we were using int as type of elements. In order to store
client defined types into the Vector (and the Vector [^topic`:`/`/Core`/src`/Overview`$en`-us^ f
lavor]) the type must satisfy [^topic`:`/`/Core`/src`/Moveable`$en`-us^ moveable]
requirement `- in short, it must not contain back`-pointers nor
virtual methods. Type must be marked as moveable in order to
define interface contract using&]
[s7; -|struct Distribution : [* Moveable]<Distribution> `{&]
[s7; -|-|String text;&]
[s7; -|-|Vector<int> data;&]
[s7; -|`};&]
[s5; Now to add Distribution elements you cannot use Add with parameter,
because it requires elements to have default deep`-copy constructor
`- and Distribution does not have one, as Vector<int> has default
pick`-constructor, so Distribution itself has pick`-constructor.
It would no be a good idea either, because deep`-copy would involve
expensive copying of inner Vector.&]
[s5; Instead, [* Add] without parameters has to be used `- it default
constructs (that is cheap) element in Vector and returns reference
to it&]
[s7; -|Vector<Distribution> dist;&]
[s7; -|for(int n `= 5; n <`= 10; n`+`+) `{&]
[s7; -|-|Distribution`& d `= dist.[* Add]();&]
[s7; -|-|d.text << `"Test `" << n;&]
[s7; -|-|for(int i `= 0; i < 10000; i`+`+)&]
[s7; -|-|-|d.data.At(rand() % n, 0)`+`+;&]
[s7; -|`}&]
[s7; &]
[s16; Test 5: `{ 2018, 1992, 2025, 1988, 1977 `}&]
[s16; Test 6: `{ 1670, 1682, 1668, 1658, 1646, 1676 `}&]
[s16; Test 7: `{ 1444, 1406, 1419, 1493, 1370, 1418, 1450 `}&]
[s16; Test 8: `{ 1236, 1199, 1245, 1273, 1279, 1302, 1250, 1216 `}&]
[s16; Test 9: `{ 1115, 1111, 1100, 1122, 1192, 1102, 1089, 1064, 1105
`}&]
[s16; Test 10: `{ 969, 956, 1002, 1023, 1006, 994, 1066, 1022, 929,
1033 `}&]
[s5; Another possibility is to use AddPick method, which uses pick`-constructor
instead of deep`-copy constructor. E.g. Distribution elements
might be generated by some function &]
[s7; -|Distribution CreateDist(int n);&]
[s5; and code for adding such elements to Vector then looks like&]
[s7; -|for(n `= 5; n <`= 10; n`+`+)&]
[s7; -|-|dist.[* AddPick](CreateDist(n));&]
[s5; alternatively, you can use default`-constructed variant too&]
[s7; -|-|dist.Add() `= CreateDist(); // alternative&]
[s7; &]
[s3; 5. Array flavor&]
[s5; If elements do not satisfy requirements for Vector flavor, they
can still be stored in Array flavor. Another reason for using
Array is need for referencing elements `- Array flavor never
invalidates references or pointers to them.&]
[s5; Example of elements that cannot be stored in Vector flavor are
STL containers (STL does not specify the NTL flavor for obvious
reasons):&]
[s7; -|[* Array]< std`::list<int> > al;&]
[s7; -|for(int i `= 0; i < 4; i`+`+) `{&]
[s7; -|-|std`::list<int>`& l `= al.Add();&]
[s7; -|-|for(int q `= 0; q < i; q`+`+)&]
[s7; -|-|-|l.push`_back(q);&]
[s7; -|`}&]
[s7; &]
[s3; 6. Polymorphic Array&]
[s5; Array can even be used for storing polymorphic elements &]
[s7; -|struct Number `{&]
[s7; -|-|virtual double Get() const `= 0;&]
[s7; &]
[s7; -|-|String ToString() const `{ return AsString(Get()); `}&]
[s7; -|`};&]
[s7; &]
[s7; -|struct Integer : public Number `{&]
[s7; -|-|int n;&]
[s7; -|-|virtual double Get() const `{ return n; `}&]
[s7; -|&]
[s7; -|-|Integer(int n) : n(n) `{`}&]
[s7; -|`};&]
[s7; &]
[s7; -|struct Double : public Number `{&]
[s7; -|-|double n;&]
[s7; -|-|virtual double Get() const `{ return n; `}&]
[s7; -|&]
[s7; -|-|Double(double n) : n(n) `{`}&]
[s7; -|`};&]
[s5; In this case, elements are added using Add with pointer to base
element type parameter. Do not be confused by new and pointer,
Array takes ownership of passed object and behaves like container
of base type elements&]
[s7; -|Array<Number> num;&]
[s7; -|num.[* Add]([* new] Integer(3));&]
[s7; -|num.Add(new Double(15.5));&]
[s7; -|num.Add(new Double(2.23));&]
[s7; -|num.Add(new Integer(2));&]
[s7; -|num.Add(new Integer(20));&]
[s7; -|num.Add(new Double(`-2.333));&]
[s17; num `= `{ 3, 15.5, 2.23, 2, 20, `-2.333 `}&]
[s5; Thanks to well defined algorithm requirements, you can e.g.
directly apply Sort on such Array&]
[s7; -|bool operator<(const Number`& a, const Number`& b)&]
[s7; -|`{&]
[s7; -|-|return a.Get() < b.Get();&]
[s7; -|`}&]
[s7; &]
[s7; .......&]
[s7; &]
[s7; -|Sort(num);&]
[s17; num `= `{ `-2.333, 2, 2.23, 3, 15.5, 20 `}&]
[s3; 7. Bidirectional containers&]
[s5; Vector and Array containers allow fast adding and removing elements
at the end of sequence. Sometimes, same is needed at begin of
sequence too (usually to support FIFO like operations). In such
case, BiVector and BiArray should be used&]
[s7; -|BiVector<int> n;&]
[s7; -|n.[* AddHead](1);&]
[s7; -|n.[* AddTail](2);&]
[s7; -|n.AddHead(3);&]
[s7; -|n.AddTail(4);&]
[s17; n `= `{ 3, 1, 2, 4 `}&]
[s7; -|n.[* DropHead]();&]
[s17; n `= `{ 1, 2, 4 `}&]
[s7; -|n.[* DropTail]();&]
[s17; n `= `{ 1, 2 `}&]
[s7; -|BiArray<Number> num;&]
[s7; -|num.AddHead(new Integer(3));&]
[s7; -|num.AddTail(new Double(15.5));&]
[s7; -|num.AddHead(new Double(2.23));&]
[s7; -|num.AddTail(new Integer(2));&]
[s7; -|num.AddHead(new Integer(20));&]
[s7; -|num.AddTail(new Double(`-2.333));&]
[s17; num `= `{ 20, 2.23, 3, 15.5, 2, `-2.333 `}&]
[s3; 8. Index&]
[s5; Index is a container very similar to the plain Vector (it is
random access array of elements with fast addition at the end)
with one unique feature `- it is able to fast retrieve position
of element with required value using [* Find] method&]
[s7; -|[* Index]<String> ndx;&]
[s7; -|ndx.[* Add](`"alfa`");&]
[s7; -|ndx.Add(`"beta`");&]
[s7; -|ndx.Add(`"gamma`");&]
[s7; -|ndx.Add(`"delta`");&]
[s7; -|ndx.Add(`"kappa`");&]
[s17; ndx `= `{ alfa, beta, gamma, delta, kappa `}&]
[s7; -|DUMP(ndx.[* Find](`"beta`"));&]
[s17; ndx.Find(`"beta`") `= 1&]
[s5; If element is not present in Index, Find returns a negative
value&]
[s7; -|DUMP(ndx.Find(`"something`"));&]
[s17; ndx.Find(`"something`") `= `-1&]
[s5; Any element can be replaced using [* Set] method&]
[s7; -|ndx.[* Set](0, `"delta`");&]
[s17; ndx `= `{ delta, beta, gamma, delta, kappa `}&]
[s5; If there are more elements with the same value, they can be
iterated using [* FindNext] method&]
[s7; -|int fi `= ndx.Find(`"delta`");&]
[s7; -|while(fi >`= 0) `{&]
[s7; -|-|DUMP(fi);&]
[s7; -|-|fi `= ndx.[* FindNext](fi);&]
[s7; -|`}&]
[s7; -|cout << `'n`';&]
[s17; 0 3-|&]
[s5; [* FindAdd] method retrieves position of element like Find, but
if element is not present in Index, it is added&]
[s7; -|DUMP(ndx.[* FindAdd](`"one`"));&]
[s7; -|DUMP(ndx.FindAdd(`"two`"));&]
[s7; -|DUMP(ndx.FindAdd(`"three`"));&]
[s7; -|DUMP(ndx.FindAdd(`"two`"));&]
[s7; -|DUMP(ndx.FindAdd(`"three`"));&]
[s7; -|DUMP(ndx.FindAdd(`"one`"));&]
[s7; &]
[s16; ndx.FindAdd(`"one`") `= 5&]
[s16; ndx.FindAdd(`"two`") `= 6&]
[s16; ndx.FindAdd(`"three`") `= 7&]
[s16; ndx.FindAdd(`"two`") `= 6&]
[s16; ndx.FindAdd(`"three`") `= 7&]
[s16; ndx.FindAdd(`"one`") `= 5&]
[s5; Removing elements from random access sequence is always expensive,
that is why rather than remove, Index supports [* Unlink] and [* UnlinkKey
]operations, which leave element in Index but make it invisible
for Find operation&]
[s7; -|ndx.[* Unlink](2);&]
[s7; -|ndx.[* UnlinkKey](`"kappa`");&]
[s7; &]
[s7; -|DUMP(ndx.Find(ndx`[2`]));&]
[s7; -|DUMP(ndx.Find(`"kappa`"));&]
[s7; &]
[s16; ndx.Find(ndx`[2`]) `= `-1&]
[s16; ndx.Find(`"kappa`") `= `-1&]
[s5; You can test whether element at given position is unlinked using
[* IsUnlinked] method&]
[s7; -|DUMP(ndx.[* IsUnlinked](1));&]
[s7; -|DUMP(ndx.IsUnlinked(2));&]
[s7; &]
[s16; ndx.IsUnlinked(1) `= 0&]
[s16; ndx.IsUnlinked(2) `= 1&]
[s5; Unlinked positions can be reused by [* Put] method&]
[s7; -|ndx.[* Put](`"foo`");&]
[s17; ndx `= `{ delta, beta, foo, delta, kappa, one, two, three `}&]
[s7; -|DUMP(ndx.Find(`"foo`"));&]
[s17; ndx.Find(`"foo`") `= 2&]
[s5; You can also remove all unlinked elements from Index using [* Sweep]
method&]
[s7; -|ndx.Sweep();&]
[s17; ndx `= `{ delta, beta, foo, delta, one, two, three `}&]
[s5; As we said, operations directly removing or inserting elements
of Index are very expensive, but sometimes this might not matter,
so they are available too&]
[s7; -|ndx.[* Remove](1);&]
[s17; ndx `= `{ delta, foo, delta, one, two, three `}&]
[s7; -|ndx.[* RemoveKey](`"two`");&]
[s17; ndx `= `{ delta, foo, delta, one, three `}&]
[s7; -|ndx.[* Insert](0, `"insert`");&]
[s17; ndx `= `{ insert, delta, foo, delta, one, three `}&]
[s5; Finally, [* PickKeys] operation allows you to obtain Vector of
elements of Index in low constant time operation (while destroying
source Index)&]
[s7; -|Vector<String> d `= ndx.[* PickKeys]();&]
[s7; -|Sort(d);&]
[s17; d `= `{ delta, delta, foo, insert, one, three `}&]
[s3; 9. Index and client types&]
[s5; In order to store elements to Index, they must be moveable (you
can use [* ArrayIndex] for types that are not) and they must have
defined the operator`=`= and a function to compute hash value.
Notice usage of [* CombineHash] to combine hash values of types
already known to U`+`+ into final result&]
[s7; -|struct Person : Moveable<Person> `{&]
[s7; -|-|String name;&]
[s7; -|-|String surname;&]
[s7; -|&]
[s7; -|-|Person(String name, String surname)&]
[s7; -|-|: name(name), surname(surname) `{`}&]
[s7; -|-|Person() `{`}&]
[s7; -|`};&]
[s7; &]
[s7; -|unsigned [* GetHashValue](const Person`& p)&]
[s7; -|`{&]
[s7; -|-|return [* CombineHash](p.name, p.surname);&]
[s7; -|`}&]
[s7; &]
[s7; -|bool operator`=`=(const Person`& a, const Person`& b)&]
[s7; -|`{&]
[s7; -|-|return a.name `=`= b.name `&`& a.surname `=`= b.surname;&]
[s7; -|`}&]
[s7; &]
[s7; .......&]
[s7; &]
[s7; -|Index<Person> p;&]
[s7; -|p.Add(Person(`"John`", `"Smith`"));&]
[s7; -|p.Add(Person(`"Paul`", `"Carpenter`"));&]
[s7; -|p.Add(Person(`"Carl`", `"Engles`"));&]
[s7; -| &]
[s7; -|DUMP(p.Find(Person(`"Paul`", `"Carpenter`")));&]
[s17; p.Find(Person(`"Paul`", `"Carpenter`")) `= 1&]
[s5; If type cannot be stored in Index or if references to elements
are required, [* ArrayIndex] can be used&]
[s7; -|unsigned GetHashValue(const Number`& n)&]
[s7; -|`{&]
[s7; -|-|return GetHashValue(n.Get());&]
[s7; -|`}&]
[s7; &]
[s7; -|bool operator`=`=(const Number`& a, const Number`& b)&]
[s7; -|`{&]
[s7; -|-|return a.Get() `=`= b.Get();&]
[s7; -|`}&]
[s7; &]
[s7; .......&]
[s7; &]
[s7; -|[* ArrayIndex]<Number> n;&]
[s7; -|n.Add(new Integer(100));&]
[s7; -|n.Add(new Double(10.5));&]
[s7; -|n.Add(new Integer(200));&]
[s7; -|n.Add(new Double(20.5));&]
[s17; n `= `{ 100, 10.5, 200, 20.5 `}&]
[s7; -|DUMP(n.Find(Double(10.5)));&]
[s17; n.Find(Double(10.5)) `= 1&]
[s3; 10. VectorMap&]
[s5; VectorMap is nothing more than a simple composition of Index
and Vector. You can use [* Add] methods to put elements into the
VectorMap&]
[s7; -|[* VectorMap]<String, Person> m;&]
[s7; -|&]
[s7; -|m.[* Add](`"1`", Person(`"John`", `"Smith`"));&]
[s7; -|m.Add(`"2`", Person(`"Carl`", `"Engles`"));&]
[s7; &]
[s7; -|Person`& p `= m.[* Add](`"3`");&]
[s7; -|p.name `= `"Paul`";&]
[s7; -|p.surname `= `"Carpenter`";&]
[s5; VectorMap provides constant access to its underlying Index and
Vector&]
[s7; -|DUMP(m.[* GetKeys]());&]
[s7; -|DUMP(m.[* GetValues]());&]
[s7; &]
[s16; m.GetKeys() `= `{ 1, 2, 3 `}&]
[s16; m.GetValues() `= `{ John Smith, Carl Engles, Paul Carpenter
`}&]
[s7; &]
[s5; You can use indices to iterate map contents&]
[s7; -|for(int i `= 0; i < m.GetCount(); i`+`+)&]
[s7; -|-|LOG(m.[* GetKey](i) << `": `" << m[* `[]i[* `]]);&]
[s7; &]
[s16; 1: John Smith&]
[s16; 2: Carl Engles&]
[s16; 3: Paul Carpenter&]
[s7; &]
[s5; You can use [* Find] method to retrieve position of element with
required key&]
[s7; -|DUMP(m.[* Find](`"2`"));&]
[s17; m.Find(`"2`") `= 1&]
[s5; or [* Get] method to retrieve corresponding value&]
[s7; -|DUMP(m.[* Get](`"2`"));&]
[s17; m.Get(`"2`") `= Carl Engles&]
[s5; Passing key not present in VectorMap as Get parameter is a logic
error, but there exists two parameter version that returns second
parameter if key is not in VectorMap&]
[s7; -|DUMP(m.Get(`"33`", Person(`"unknown`", `"person`")));&]
[s17; m.Get(`"33`", Person(`"unknown`", `"person`")) `= unknown person&]
[s5; As with Index, you can use [* Unlink] to make elements invisible
for Find operations&]
[s7; -|m.Unlink(1);&]
[s7; -|DUMP(m.Find(`"2`"));&]
[s17; m.Find(`"2`") `= `-1&]
[s5; You can use [* SetKey] method to change the key of the element&]
[s7; -|m.[* SetKey](1, `"33`");&]
[s7; -|DUMP(m.Get(`"33`", Person(`"unknown`", `"person`")));&]
[s17; m.Get(`"33`", Person(`"unknown`", `"person`")) `= Carl Engles&]
[s5; If there are more elements with the same key in VectorMap, you
can iterate them using [* FindNext] method&]
[s7; -|m.Add(`"33`", Person(`"Peter`", `"Pan`"));&]
[s7; &]
[s16; m.GetKeys() `= `{ 1, 33, 3, 33 `}&]
[s16; m.GetValues() `= `{ John Smith, Carl Engles, Paul Carpenter,
Peter Pan `}&]
[s7; &]
[s7; -|int q `= m.Find(`"33`");&]
[s7; -|while(q >`= 0) `{&]
[s7; -|-|cout << m`[q`] << `'n`';&]
[s7; -|-|q `= m.[* FindNext](q);&]
[s7; -|`}&]
[s7; -|&]
[s16; Carl Engles&]
[s16; Peter Pan&]
[s7; &]
[s5; You can reuse unlinked positions using [* Put] method&]
[s7; -|m.[* UnlinkKey](`"33`");&]
[s7; -|m.[* Put](`"22`", Person(`"Ali`", `"Baba`"));&]
[s7; -|m.Put(`"44`", Person(`"Ivan`", `"Wilks`"));&]
[s7; &]
[s16; m.GetKeys() `= `{ 1, 22, 3, 44 `}&]
[s16; m.GetValues() `= `{ John Smith, Ali Baba, Paul Carpenter, Ivan
Wilks `}&]
[s7; &]
[s5; [* GetSortOrder] algorithm returns order of elements as Vector<int>
container. You can use it to order content of VectorMap without
actually moving its elements&]
[s7; -|bool operator<(const Person`& a, const Person`& b)&]
[s7; -|`{&]
[s7; -|-|return a.surname `=`= b.surname ? a.name < b.name&]
[s7; -| : a.surname < b.surname;&]
[s7; -|`}&]
[s7; &]
[s7; .......&]
[s7; &]
[s7; -|Vector<int> order `= [* GetSortOrder](m.GetValues());&]
[s17; order `= `{ 1, 2, 0, 3 `}&]
[s7; -|for(int i `= 0; i < order.GetCount(); i`+`+)&]
[s7; -|-|cout << m.GetKey(order`[i`]) << `": `" << m`[order`[i`]`] <<
`'n`';&]
[s7; &]
[s16; 22: Ali Baba&]
[s16; 3: Paul Carpenter&]
[s16; 1: John Smith&]
[s16; 44: Ivan Wilks&]
[s7; &]
[s5; You can get Vector of values or keys using [* PickValues] resp.
[* PickKeys] methods in low constant time, while destroying content
of source VectorMap&]
[s7; -|Vector<Person> ps `= m.[* PickValues]();&]
[s17; ps `= `{ John Smith, Ali Baba, Paul Carpenter, Ivan Wilks `}&]
[s5; If type of values does not satisfy requirements for Vector elements
or if references to elements are needed, you can use [* ArrayMap]
instead&]
[s7; -|[* ArrayMap]<String, Number> am;&]
[s7; -|am.Add(`"A`", new Integer(1));&]
[s7; -|am.Add(`"B`", new Double(2.0));&]
[s7; &]
[s16; am.GetKeys() `= `{ A, B `}&]
[s16; am.GetValues() `= `{ 1, 2 `}&]
[s7; &]
[s7; -|DUMP(am.Get(`"A`"));&]
[s7; -|DUMP(am.Find(`"B`"));&]
[s7; &]
[s16; am.Get(`"A`") `= 1&]
[s16; am.Find(`"B`") `= 1&]
[s16; &]
[s0; ]

View file

@ -1,75 +1,38 @@
TITLE("NTL and standard library") topic "NTL and standard library";
COMPRESSED [2 $$0,0#00000000000000000000000000000000:Default]
120,156,133,84,93,111,219,54,20,253,43,68,157,13,77,234, [l288;i704;a17;O9;~~~.992;2 $$1,0#10431211400427159095818037425705:param]
24,188,252,166,245,210,34,237,128,2,91,10,172,221,246,96, [a83;*R6 $$2,5#31310162474203024125188417583966:caption]
4,53,173,48,177,22,89,242,68,58,169,49,44,191,125,135, [b83;*2 $$3,5#07864147445237544204411237157677:title]
178,147,118,232,195,108,88,17,20,158,123,62,238,189,90,8, [b167;a42;C2 $$4,6#40027414424643823182269349404212:item]
118,114,194,167,124,194,255,231,51,127,27,111,194,174,205,87, [b42;a42;2 $$5,5#45413000475342174754091244180557:text]
139,86,56,87,53,150,171,42,144,173,62,248,234,241,241,113, [l288;a17;2 $$6,6#27521748481378242620020725143825:desc]
230,189,168,74,41,66,41,226,74,146,32,82,156,43,97,73, [l321;tC@5;1 $$7,7#20902679421464641399138805415013:code]
123,238,181,35,199,165,85,66,91,174,231,219,48,132,205,213, [b2503;2 $$8,0#65142375456100023862071332075487:separator]
34,56,89,157,253,106,128,18,83,61,145,36,137,147,17,10, [*@(0.0.255)2 $$9,0#83433469410354161042741608181528:base]
167,184,228,66,145,208,228,156,34,171,157,244,198,204,235,176, [tC7 $$10,0#37138531426314131251341829483380:class]
205,77,223,93,45,86,5,7,148,4,138,91,103,20,1,163, [l288;a17;*1 $$11,11#70004532496200323422659154056402:requirement]
180,144,86,43,96,149,34,194,61,105,107,172,157,231,38,183, [i417;b42;a42;O9;~~~.416;2 $$12,12#10566046415157235020018451313112:tparam]
17,24,50,182,10,74,84,23,69,165,154,154,9,212,9,11, [b167;C2 $$13,13#92430459443460461911108080531343:item1]
168,18,202,40,233,132,36,39,132,241,82,121,5,217,36,230, [i288;a42;O9;C2 $$14,14#77422149456609303542238260500223:item2]
77,142,16,185,2,166,224,10,76,131,80,105,69,18,121,40, [*@2$(0.128.128)2 $$15,15#34511555403152284025741354420178:NewsDate]
171,37,142,89,252,85,220,147,0,171,227,90,131,48,126,121, [l321;*C$7;2 $$16,16#03451589433145915344929335295360:result]
10,169,228,83,112,6,116,194,234,114,218,41,71,210,58,161, [l321;b83;a83;*C$7;2 $$17,17#07531550463529505371228428965313:result`-line]
132,17,16,192,45,76,22,118,61,191,142,169,6,78,10,170, [l160;*tC+117 $$18,5#88603949442205825958800053222425:package`-title]
50,36,85,23,175,117,69,0,219,169,157,8,238,185,48,214, [{_}%EN-US
131,16,98,97,88,122,79,210,129,80,145,230,36,231,117,127, [s2; NTL and standard library&]
93,76,10,205,101,5,140,67,23,12,10,143,145,104,67,208, [s5; While NTL is kind of `"alien technology`" with respect to C`+`+
43,164,3,163,37,41,113,213,202,217,121,138,165,15,185,31, standard library, in fact it is largely inter`-operable with
174,22,103,175,95,242,25,159,9,173,79,139,94,15,184,147, it.&]
74,74,101,188,34,46,193,130,26,170,196,101,56,58,73,90, [s3; Iterators&]
184,249,42,36,80,102,85,130,189,40,157,47,83,132,216,165, [s5; Each NTL container (with exception of One) provides iterator
211,18,204,6,23,116,20,246,36,146,17,94,57,41,29,159, access. All iterators satisfy STL requirements for random access
215,109,72,233,155,120,206,138,69,162,41,209,196,150,84,181, iterators. This also means that most of STL (and STL based) algorithms
20,202,151,104,164,64,188,194,104,79,200,87,27,197,197,124, can be used with NTL containers.&]
136,127,237,154,33,110,98,135,128,27,12,70,245,212,156,227, [s3; auto`_ptr&]
16,66,203,97,8,197,148,4,198,80,27,195,75,90,26,179, [s5; Funny part about standard library and NTL relationship is that
32,164,70,220,156,156,130,34,124,209,224,124,156,195,113,54, any known (and imaginable) implementation of auto`_ptr is moveable
198,185,32,57,37,57,241,66,73,40,241,74,33,0,20,32, `- so you can store it into any flavor of containers. All you
79,68,220,225,11,103,136,101,156,12,130,132,209,196,129,254, need to do is to mark an instantiation with the Moveable template.&]
0,87,83,82,19,139,1,70,159,188,42,244,94,150,248,4, [s5; Even better is that you do not need Vector of auto`_ptr `- because
210,23,134,107,180,65,28,224,162,132,46,78,16,59,9,87, Array flavor will do the same job more comfortably.&]
126,167,5,175,167,132,69,128,66,210,26,182,37,130,22,14, [s0; ]
214,53,146,151,227,112,147,117,243,203,248,144,222,134,28,143,
211,114,118,113,114,24,51,50,83,50,19,94,240,218,121,180,
143,84,137,79,42,229,133,151,82,11,175,165,225,136,49,29,
246,184,128,203,46,141,123,248,92,196,78,201,98,173,96,85,
107,152,31,97,48,110,169,72,17,206,155,18,194,177,200,242,
188,109,186,162,3,115,81,29,70,225,236,226,21,145,45,133,
28,182,197,57,195,165,71,22,136,128,107,140,57,222,4,14,
125,70,155,5,118,160,188,10,234,187,112,27,151,231,199,61,
253,251,243,63,63,188,187,60,255,237,35,91,36,81,177,203,
79,63,179,208,93,179,148,113,13,195,53,107,155,213,16,134,
253,143,87,139,164,43,246,199,186,105,227,120,168,73,236,174,
193,193,254,134,45,95,132,182,137,29,203,177,94,119,125,219,
223,238,151,47,216,67,147,215,12,162,183,177,206,44,247,236,
98,249,106,249,234,187,178,83,214,116,236,38,224,72,147,75,
201,54,12,183,177,221,227,105,142,195,242,188,223,198,33,172,
192,56,86,107,242,172,200,192,194,189,199,127,203,34,165,163,
172,119,161,94,143,170,234,190,203,1,9,13,236,229,8,137,
95,234,56,190,196,138,206,15,93,60,101,219,161,191,111,176,
250,168,118,168,193,66,93,199,148,102,236,77,219,62,63,76,
44,133,220,164,155,61,251,136,170,223,236,65,98,55,128,12,
112,209,111,142,200,175,160,25,251,180,134,137,208,166,158,109,
98,232,18,203,235,144,217,166,79,185,240,151,82,47,75,184,
229,166,108,243,245,41,206,222,246,3,148,110,18,171,67,199,
86,145,237,240,252,224,247,63,134,210,147,247,176,203,253,242,
243,54,15,71,239,63,237,186,110,207,176,89,153,133,85,191,
203,223,101,60,246,243,114,180,209,134,146,69,90,55,219,18,
246,40,46,0,124,215,245,15,221,65,90,179,9,183,77,87,
50,63,197,253,182,29,77,135,167,4,159,185,11,124,211,223,
199,177,57,203,115,6,195,251,126,55,90,72,72,34,142,237,
236,208,246,82,254,166,13,247,8,13,248,111,220,140,113,23,
76,23,225,23,39,175,251,81,19,146,11,195,29,112,192,23,
39,185,57,176,143,137,228,117,100,191,60,209,98,169,183,48,
20,103,79,67,112,31,75,128,25,221,120,118,87,8,80,184,
235,243,129,231,119,76,227,65,202,87,43,144,191,138,117,64,
238,236,205,48,132,103,189,15,13,20,2,92,72,83,216,68,
246,103,191,130,105,152,171,251,13,166,32,67,197,126,36,231,
149,100,87,255,2,65,196,57,120,

File diff suppressed because it is too large Load diff

View file

@ -333,14 +333,31 @@ void TopicEditor::FixTopic()
RichText result; RichText result;
const RichText& txt = editor.Get(); const RichText& txt = editor.Get();
bool started = false; bool started = false;
int l, h;
if(editor.GetSelection(l, h)) {
l = txt.FindPart(l);
h = txt.FindPart(h);
}
else {
l = 0;
h = txt.GetPartCount();
}
for(int i = 0; i < txt.GetPartCount(); i++) for(int i = 0; i < txt.GetPartCount(); i++)
if(txt.IsPara(i)) { if(txt.IsPara(i)) {
RichPara p = txt.Get(i); RichPara p = txt.Get(i);
if(i >= l && i < h) {
WString h = p.GetText(); WString h = p.GetText();
String nat; String nat;
for(const wchar *s = h; *s; s++) const wchar *s = h;
if((byte )*s < 128 || *s == 160) while(*s)
nat.Cat(*s == 160 ? ' ' : *s); if(*s == 160 || *s == ' ') {
nat.Cat(' ');
while(*s == 160 || *s == ' ') s++;
}
else
nat.Cat(*s++);
int q = natural.Find(nat); int q = natural.Find(nat);
if(q >= 0) { if(q >= 0) {
started = true; started = true;
@ -357,6 +374,9 @@ void TopicEditor::FixTopic()
if(!started || p.GetLength()) if(!started || p.GetLength())
result.Cat(p); result.Cat(p);
} }
else
result.Cat(p);
}
else { else {
RichTable b; RichTable b;
b <<= txt.GetTable(i); b <<= txt.GetTable(i);