SortedVectors.jl
Lightweight wrapper to declare that a vector is sorted.
Install / Use
/learn @tpapp/SortedVectors.jlREADME
SortedVectors
A very lightweight Julia package to declare that a vector is sorted.
Installation
The package is registered. Type ] to enter pkg mode, and install with
pkg> add SortedVectors
Features
- lightweight wrapper
- customizable order (any
Base.Order.Ordering) - constructor sorts argument by default, this can be skipped, or just verified
setindex!checks that order is maintained- fast implementation for
in
Documentation
See the docstring for SortedVector, the only exported symbol.
Example
julia> using SortedVectors
julia> sv = SortedVector([1, 3, 4])
3-element SortedVector{Int64, Vector{Int64}, Base.Order.ForwardOrdering}:
1
3
4
julia> sv[2]
3
julia> 2 ∈ sv
false
julia> sv[2] = 7
ERROR: ArgumentError: Order.lt(order, x, sorted_contents[i + 1]) must hold. Got
Order.lt => lt
order => ForwardOrdering()
x => 7
sorted_contents[i + 1] => 4
Stacktrace:
[1] throw_check_error(info::Any)
@ ArgCheck ~/.julia/packages/ArgCheck/CA5vv/src/checks.jl:280
[2] setindex!(sorted_vector::SortedVector{Int64, Vector{Int64}, Base.Order.ForwardOrdering}, x::Int64, i::Int64)
@ SortedVectors ~/code/julia/SortedVectors/src/SortedVectors.jl:104
Related Skills
node-connect
342.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
85.3kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
342.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
342.5kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
