-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathRingArray.hs
More file actions
92 lines (77 loc) · 1.82 KB
/
RingArray.hs
File metadata and controls
92 lines (77 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{-# LANGUAGE CPP #-}
-- |
-- Module : Streamly.Data.RingArray
-- Copyright : (c) 2025 Composewell Technologies
--
-- License : BSD3
-- Maintainer : streamly@composewell.com
-- Stability : released
-- Portability : GHC
--
-- This module provides APIs to create and use unboxed, mutable ring arrays of
-- fixed size. Ring arrays are useful to keep a circular buffer or a sliding
-- window of elements.
--
-- RingArrays are of fixed size but there is a way to expand the size of the
-- ring, you can copy the ring to a MutArray, expand the MutArray and the cast
-- it back to RingArray.
--
-- This module is designed to be imported qualified:
--
-- >>> import qualified Streamly.Data.RingArray as Ring
--
-- Please refer to "Streamly.Internal.Data.RingArray" for functions that have
-- not yet been released.
--
module Streamly.Data.RingArray
( RingArray
-- * Construction
, createOfLast
, castMutArray -- XXX this is unsafeFreeze in Array module
, castMutArrayWith
-- , unsafeCastMutArray
-- , unsafeCastMutArrayWith
-- * Moving the Head
, moveForward
, moveReverse
-- , moveBy
-- * In-place Mutation
, insert
, replace
, replace_
, putIndex
, modifyIndex
-- * Random Access
, getIndex
, unsafeGetIndex
, unsafeGetHead
-- * Conversion
, toList
, toMutArray
-- * Streams
, read
, readRev
-- * Unfolds
, reader
, readerRev
-- * Size
, length
, byteLength
-- * Casting
, cast
-- , unsafeCast
, asBytes
, asMutArray
-- , asMutArray_
-- * Folds
-- , foldlM'
, fold
-- * Stream of Rings
, ringsOf
, scanRingsOf
-- * Fast Byte Comparisons
, eqArray
, eqArrayN
) where
import Streamly.Internal.Data.RingArray
import Prelude hiding (read, length)