Non-exported names

Public names

SmallCollections.bitsizeFunction
SmallCollections.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.

source
SmallCollections.defaultFunction
SmallCollections.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.

source
SmallCollections.isfasttypeFunction
SmallCollections.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.

source
SmallCollections.MapStyleType
SmallCollections.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 function f is only evaluated when strictly necessary, and it is not assumed to be defined for default values. This is the default MapStyle 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 as RigidStyle 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()
source

Internal names

These names are not public and may change in future versions.

SmallCollections.element_typeFunction
SmallCollections.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
source
SmallCollections.top_set_bitFunction
SmallCollections.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.

source
SmallCollections.pdepFunction
SmallCollections.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.

source