DuplicatePolicy Enumeration

Describes how duplicate values are handled when inserting into a SortedArray. A "duplicate" value is one that compares equal to a value already present in the array, per the array's comparison function.

Members

Name Value Description
Allow 0 The array allows duplicate values to be inserted. All duplicate values will be adjacent in the array, but the ordering between duplicate values is unspecified.

note In the presence of duplicate values, functions like SortedArray.indexOf and SortedArray.findEqual will return one of the values - exactly which one is unspecified.
Retain 1 Duplicate values are forbidden - when attempting to insert a value equivalent to one already present, the already-present value is retained.
Replace 2 Duplicate values are forbidden - when attempting to insert a value equivalent to one already present, the already-present value is replaced by the new value.
This can be useful when the value type carries additional data that is not evaluated by the comparison function.

Defined in

Last Updated: 30 November, 2023