UnorderedSet
The UnorderedSet object is container that stores one or more unique objects. It is similar to a StringSet except it can store variants of any type (rather than just strings), and the contents are not kept sorted (in fact, the order of set members is unspecified). Like a StringSet it uses a dictionary system to locate members rather than numeric indexes. You can therefore lookup members much more quickly than by linearly searching a Vector.
You can create a new UnorderedSet using the **DOpusFactory**object.
Care should be taken when adding objects to an UnorderedSet. Unlike strings and numbers, the container will only consider two objects equal if both are the exact same object (i.e. same instance/reference). Two separate objects with the same value will not be considered equal, and can both exist in the same UnorderedSet at once.
JScript Example:
That will output the following (order of items may vary):
count
int
Returns the number of elements the UnorderedSet currently holds.
empty
bool
Returns True if the UnorderedSet is empty, False if not.
length
int
A synonym for count.
size
int
A synonym for count.
Method Name
Arguments
Return Type
Description
assign
<UnorderedSet:from>
none
Copies the contents of another UnorderedSet to this one. You can also pass an array or Vector object.
clear
none
none
Clears the contents of the UnorderedSet.
erase
variant
none
Erases the element if it exists in the set.
exists
variant
bool
Returns True if the specified element exists in the set.
insert
variant
bool
Inserts the element into the set if it doesn't already exist. Returns True if successful.
merge
<UnorderedSet:from>
none
Merges the contents of another UnorderedSet with this one.
最后更新于