Skip to content

Array buffers with growing indexing for array data streams

License

Notifications You must be signed in to change notification settings

sairus7/OffsetBuffers.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OffsetBuffers.jl

Installation

]add https://github.com/sairus7/OffsetBuffers.jl.git

Description

Buffer counts items pushed to the end and uses counted value as index for last buffered items.

There are two types of OffsetBuffers:

  • RollingBuffer - data items are stored in a circular fashion, same as CircularBuffer at DataStructures.jl package.
  • SlidingBuffer - data items are stored contigiously in memory from old to new, so you can always work with underlying array.

Both types behave the same way, only differing in its internal representation.

julia> buf = RollingBuffer{Int}(5)
0-element RollingBuffer{Int64} with indices OffsetBuffers.URange(1,0)

julia> append!(buf, [10, 20, 30])
3-element RollingBuffer{Int64} with indices OffsetBuffers.URange(1,3):
 10
 20
 30

julia> append!(buf, [40, 50])
5-element RollingBuffer{Int64} with indices OffsetBuffers.URange(1,5):
 10
 20
 30
 40
 50

julia> append!(buf, [60, 70])
5-element RollingBuffer{Int64} with indices OffsetBuffers.URange(4,8):
 30
 40
 50
 60
 70
 
julia> firstindex(buf)
3

julia> buf[3] # == first(buf)
30

julia> lastindex(buf)
7

julia> buf[7] # == last(buf)
70

About

Array buffers with growing indexing for array data streams

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages