Non-exported names
Public names
SmallCollections.bitsize
— FunctionSmallCollections.bitsize(T::Type) -> Int
SmallCollections.bitsize(x::T) where T -> Int
Return the size of the internal binary representation of T
in bits. For Bool
the function returns 1
.
See also Base.sizeof
.
SmallCollections.default
— FunctionSmallCollections.default(::Type{T}) where T -> T
SmallCollections.default(::T) where T -> T
Return the default value of type T
used for filling unused elements of an AbstractSmallVector
. This must be defined as zero(T)
if T
supports algebraic operations. Otherwise it can be any value of type T
.
This function has methods for number types, bits types, Symbol
, AbstractChar
, AbstractString
, Tuple
, NamedTuple
, AbstractFixedVector
, AbstractSmallVector
und SmallBitSet
. Methods for other types must be defined explicitly.
See also Base.isbitstype
.
SmallCollections.FixedVectorStyle
— TypeSmallCollections.FixedVectorStyle <: Broadcast.AbstractArrayStyle{1}
The broadcasting style used for AbstractFixedVector
.
See also AbstractFixedVector
, Broadcast.AbstractArrayStyle
.
SmallCollections.SmallVectorStyle
— TypeSmallCollections.SmallVectorStyle <: Broadcast.AbstractArrayStyle{1}
The broadcasting style used for AbstractSmallVector
.
See also AbstractSmallVector
, Broadcast.AbstractArrayStyle
.
SmallCollections.isfasttype
— FunctionSmallCollections.isfasttype(::Type{T}) where T -> Bool
Return true
if elements of type T
permit fast (for instance, vectorized) operations.
By default, Base.HWReal
, Bool
, Char
, and Enum
types are considered fast, as well as Complex
, Pair
, Tuple
, NamedTuple
and Ref
with fast components.
See Base.HWReal
.
SmallCollections.MapStyle
— TypeSmallCollections.MapStyle
MapStyle(f, types::Type...) -> MapStyle
A MapStyle
determines how SmallCollections
evaluates certain functions like map
or findfirst
that take a function f
as argument. The available subtypes of MapStyle
are as follows, from the least to the most efficient:
LazyStyle
: the functionf
is only evaluated when strictly necessary, and it is not assumed to be defined for default values. This is the defaultMapStyle
for unknown functions.EagerStyle
:f
may be evaluated more often than strictly necessary, and it is assumed to be defined for default values. However, it need not map default values to default values.RigidStyle
:f
may be evaluated more often than strictly necessary. It is assumed to be defined for default values and to return a default value if all arguments are default values.StrictStyle
:f
may be evaluated more often than strictly necessary. It is assumed to be defined for default values and to return a default value if at least one argument is a default value. (This is the same asRigidStyle
for functions with a single argument.)
The MapStyle
is predefined for many functions from Base
as well as for operations that produce new functions out of old. Unnamed functions are not recognized. However, several functions from SmallCollections
allow to specify a MapStyle
as keyword argument. In addition, users can define a MapStyle
for their own types.
See also SmallCollections.default
, SmallCollections.isfasttype
.
Examples
julia> using SmallCollections: MapStyle
julia> MapStyle(iszero, Int) # not RigidStyle: iszero(0) is true, not false
SmallCollections.EagerStyle()
julia> MapStyle(+, Int, Int)
SmallCollections.RigidStyle()
julia> MapStyle(*, Int, Float64) # not StrictStyle: 0 * Inf is NaN, not 0.0
SmallCollections.RigidStyle()
julia> MapStyle(*, Int, Int)
SmallCollections.StrictStyle()
julia> MapStyle(-, Int)
SmallCollections.StrictStyle()
julia> MapStyle(x -> -x, Int) # not StrictStyle: anonymous function not recognized
SmallCollections.LazyStyle()
julia> MapStyle(-, Int128) # Int128 is not a fast type, so better be lazy
SmallCollections.LazyStyle()
julia> MapStyle(isfinite∘inv, Float64) # function composition is recognized
SmallCollections.EagerStyle()
julia> MapStyle(!iszero, Int) # function composition again
SmallCollections.EagerStyle()
julia> MapStyle(>=(1), Int) # >=(1) is Base.Fix2(>=, 1), which is recognized
SmallCollections.EagerStyle()
Internal names
These names are not public and may change in future versions.
SmallCollections.element_type
— FunctionSmallCollections.element_type(itr) -> Type
SmallCollections.element_type(::Type) -> Type
Return the element type of an iterator or its type. This differs from eltype
in that the element type of a Tuple
or NamedTuple
is determined via promote_type
instead of promote_typejoin
. For all other iterators there is no difference.
See also Base.eltype
, Base.promote_type
, Base.promote_typejoin
.
Example
julia> eltype((1, 2, 3.0))
Real
julia> SmallCollections.element_type((1, 2, 3.0))
Float64
SmallCollections.AbstractBitInteger
— TypeSmallCollections.AbstractBitInteger
This type is the union of Base.BitInteger
, BitIntegers.AbstractBitSigned
and BitIntegers.AbstractBitUnsigned
.
SmallCollections.top_set_bit
— FunctionSmallCollections.top_set_bit(x::AbstractBitInteger) -> Int
Return the position of the highest set bit in x
(counting from 1
), or return 0
if x
is 0
.
This function is analogous to Julia's internal function Base.top_set_bit
, but it is also fast and correct for bit integers defined by BitIntegers.jl
.
See also Base.top_set_bit
, SmallCollections.AbstractBitInteger
.
SmallCollections.unsafe_shl
— FunctionSmallCollections.unsafe_shl(x::U, i::Integer) where U <: AbstractBitInteger -> U
This is a fast, but unsafe version of the left bit shift operator x << i
. The shift i
is assumed to be between 0
and bitsize(x)-1
.
See also SmallCollections.bitsize
, SmallCollections.AbstractBitInteger
.
SmallCollections.unsafe_lshr
— FunctionSmallCollections.unsafe_lshr(x::U, i::Integer) where U <: AbstractBitInteger -> U
This is a fast, but unsafe version of the logical (or unsigned) right bit shift operator x >>> i
. The shift i
is assumed to be between 0
and bitsize(x)-1
.
See also SmallCollections.bitsize
, SmallCollections.AbstractBitInteger
.
SmallCollections.pdep
— FunctionSmallCollections.pdep(x::Unsigned, y::U) where U <: Unsigned -> U
Assume that y
has exactly m
1
-bits. Then pdep(x, y)
replaces these bits by the m
lowest bits of x
(in order) and returns the result. The remaining bits of x
are ignored.
On x86_64
and i686
machines, this function uses the corresponding instruction from the BMI2 instruction set if possible. Without hardware support it is much slower.