:orphan: .. **************************************************************************** .. CUI .. .. The Advanced Framework for Simulation, Integration, and Modeling (AFSIM) .. .. The use, dissemination or disclosure of data in this file is subject to .. limitation or restriction. See accompanying README and LICENSE for details. .. **************************************************************************** Set --- .. class:: Set inherits Object :constructible: :container: :cloneable: :class:`Set\` is a container type that stores a sorted set of unique elements of type T. For example, Set 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, :ref:`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 :ref:`basic types` or a script class with a defined ordering (e.g. :class:`WsfTrackId`) in the set. For example: * Store the integer platform index, rather than :class:`WsfPlatform`, and lookup the platform using :method:`WsfSimulation.FindPlatform`. * Store the track id, rather than :class:`WsfLocalTrack`, and lookup the track from the platform's track manager. Methods ======= .. method:: int Size() Returns the current number of elements in the set. .. method:: bool Empty() Returns true if there are no elements in the set. .. method:: bool Erase(T aData) Erases the specified set element. .. method:: void Clear() Clears the set. .. method:: bool Exists(T aData) Returns true if the specified set element exists. .. method:: void Insert(T aData) Inserts an element into the set. .. method:: Set Union(Set 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}. .. method:: Set Difference(Set aSet) Returns a Set that is the difference of the two Sets. For example, {1, 2, 3} difference {3, 4, 5} produces {1, 2}. .. method:: Set Intersection(Set aSet) Returns a Set that is the intersection of the two Sets. For example, {1, 2, 3} intersection {3, 4, 5} produces {3}. .. method:: SetIterator GetIterator() Returns an iterator that points to the beginning of the set. This is used by the script language to support the :ref:`foreach>` command, but may also be used directly.