From 2a94533edf620048242b7c5826168ef63faf4b9c Mon Sep 17 00:00:00 2001 From: Matt Bauman Date: Mon, 11 Mar 2019 20:59:42 -0400 Subject: [PATCH] Document both InvertedIndex and Not --- src/InvertedIndices.jl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/InvertedIndices.jl b/src/InvertedIndices.jl index 0d134d9..8754470 100644 --- a/src/InvertedIndices.jl +++ b/src/InvertedIndices.jl @@ -4,6 +4,13 @@ export InvertedIndex, Not using Base: tail +struct InvertedIndex{S} + skip::S +end +const Not = InvertedIndex +# Support easily inverting multiple indices without a temporary array in Not([...]) +InvertedIndex(i₁::Integer, i₂::Integer, iₓ::Integer...) = InvertedIndex(TupleVector((i₁, i₂, iₓ...))) + """ InvertedIndex(idx) Not(idx) @@ -18,12 +25,8 @@ checked to ensure that all indices in `idx` are within the bounds of the array dimensions (like a multidimensional logical mask or `CartesianIndex`), then the inverted index will similarly span multiple dimensions. """ -struct InvertedIndex{S} - skip::S -end -const Not = InvertedIndex -# Support easily inverting multiple indices without a temporary array in Not([...]) -InvertedIndex(i₁::Integer, i₂::Integer, iₓ::Integer...) = InvertedIndex(TupleVector((i₁, i₂, iₓ...))) +InvertedIndex, Not + # A very simple and primitive static array to avoid allocations for Not(1,2,3) while fulfilling the indexing API struct TupleVector{T<:Tuple} <: AbstractVector{Int}