Set¶
-
Set<T> inherits ObjectConstruction:
Set<T> newObj = Set<T>();
Clone:Set<T> newObj = Set<T>(other);
Container
Set<T> is a container type that stores a sorted set of unique elements of type T. For example, Set<int> is a set of integers. It is similar to the C++ STL set.
Tip
The elements of a Set are sorted using the ordering defined on its value type (T). With a few exceptions, script classes have no defined ordering, and using them as the value type will result in non-determinism when iterating over the elements of the Set. It is recommended in these use cases to store only basic types or a script class with a defined ordering (e.g. WsfTrackId) in the set. For example:
Store the integer platform index, rather than WsfPlatform, and lookup the platform using WsfSimulation.FindPlatform.
Store the track id, rather than WsfLocalTrack, and lookup the track from the platform’s track manager.
Methods¶
- int Size()¶
Returns the current number of elements in the set.
- bool Empty()¶
Returns true if there are no elements in the set.
- bool Erase(T aData)¶
Erases the specified set element.
- void Clear()¶
Clears the set.
- bool Exists(T aData)¶
Returns true if the specified set element exists.
- void Insert(T aData)¶
Inserts an element into the set.
- Set<T> Union(Set<T> aSet)¶
Returns a Set that is the union of the two Sets. For example, {1, 2, 3} union {3, 4, 5} produces {1, 2, 3, 4, 5}.
- Set<T> Difference(Set<T> aSet)¶
Returns a Set that is the difference of the two Sets. For example, {1, 2, 3} difference {3, 4, 5} produces {1, 2}.
- Set<T> Intersection(Set<T> aSet)¶
Returns a Set that is the intersection of the two Sets. For example, {1, 2, 3} intersection {3, 4, 5} produces {3}.
- SetIterator GetIterator()¶
Returns an iterator that points to the beginning of the set. This is used by the script language to support the foreach command, but may also be used directly.