HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulelinear-base-0.4.0Haskell2010

Data.Vector.Mutable.Linear.Internal

  • 1 type
  • 29 values
valueconstGrowthFactor :: Int
#

When growing the vector, capacity will be multiplied by this number.

This is usually chosen between 1.5 and 2; 2 being the most common.

datadata Vector a where
#

A dynamic mutable vector.

Constructors

Instances5Functor, Consumable, Dupable, Semigroup
  • Functor VectorDefined in linear-base-0.4.0 · Data.Vector.Mutable.Linear.Internal
  • Semigroup (Vector a)Defined in linear-base-0.4.0 · Data.Vector.Mutable.Linear.Internal
  • Consumable (Vector a)Defined in linear-base-0.4.0 · Data.Vector.Mutable.Linear.Internal
  • Dupable (Vector a)Defined in linear-base-0.4.0 · Data.Vector.Mutable.Linear.Internal
  • Semigroup (Vector a)Defined in linear-base-0.4.0 · Data.Vector.Mutable.Linear.Internal
valuefromArray :: HasCallStack => Array a %1 -> Vector a
#

Create a Vector from an Array. Result will have the size and capacity equal to the size of the given array.

This is a constant time operation.

valuesize :: Vector a %1 -> (Ur Int, Vector a)
#

Number of elements inside the vector.

This might be different than how much actual memory the vector is using. For that, see: capacity.

valuecapacity :: Vector a %1 -> (Ur Int, Vector a)
#

Capacity of a vector. In other words, the number of elements the vector can contain before it is copied to a bigger array.

valuepush :: a -> Vector a %1 -> Vector a
#

Insert at the end of the vector. This will grow the vector if there is no empty space.

valueset :: HasCallStack => Int -> a -> Vector a %1 -> Vector a
#

Write to an element . Note: this will not write to elements beyond the current size of the vector and will error instead.

valueget :: HasCallStack => Int -> Vector a %1 -> (Ur a, Vector a)
#

Read from a vector, with an in-range index and error for an index that is out of range (with the usual range 0..size-1).

valuemodify
  1. :: HasCallStack
  2. => a -> (a, b)
  3. -> Int
  4. -> Vector a
  5. -> (Ur b, Vector a)
#

Modify a value inside a vector, with an ability to return an extra information. Errors if the index is out of bounds.

valuetoList :: Vector a %1 -> Ur [a]
#

Return the vector elements as a lazy list.

valueshrinkToFit :: Vector a %1 -> Vector a
#

Resize the vector to not have any wasted memory (size == capacity). This returns a semantically identical vector.

valueslice :: Int -> Int -> Vector a %1 -> Vector a
#

Return a slice of the vector with given size, starting from an offset.

Start offset + target size should be within the input vector, and both should be non-negative.

This is a constant time operation if the start offset is 0. Use shrinkToFit to remove the possible wasted space if necessary.

valuegrowToFit :: HasCallStack => Int -> Vector a %1 -> Vector a
#

Grows the vector to the closest power of growthFactor to fit at least n more elements.

valueunsafeResize :: HasCallStack => Int -> Vector a %1 -> Vector a
#

Resize the vector to a non-negative size. In-range elements are preserved, the possible new elements are bottoms.