A very lightweight Julia package to declare that a vector is sorted.
Type ] to enter pkg mode, and install with
pkg> add SortedVectorsThe only exported symbol is SortedVector. Use
SortedVector([lt=isless], xs)to sort xs and save the result in a vector. xs can be any <: AbstractVector. For immutable types (eg StaticArrays.SVector or UnitRange), setindex! will not work.
If your code emits sorted vectors, use the
SortedVector(SortedVectors.AssumeSorted(), lt, sorted_contents)constructor. This will skip checks.
If your API accepts sorted vectors, and you want to check them, use the
SortedVector(SortedVectors.CheckSorted(), lt, sorted_contents)constructor.
In either case, you are responsible for ensuring that the argument vector is not modified later on. copy if you are unsure.
setindex! verifies that sorting is maintained.