https://github.com/denius/unitrangessortedsets.jl

Sorted set of unit ranges.

https://github.com/denius/unitrangessortedsets.jl

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (7.4%) to scientific vocabulary

Keywords

datastructures julia julialang
Last synced: 6 months ago · JSON representation

Repository

Sorted set of unit ranges.

Basic Info
  • Host: GitHub
  • Owner: denius
  • License: mit
  • Language: Julia
  • Default Branch: main
  • Homepage:
  • Size: 185 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 3
Topics
datastructures julia julialang
Created about 3 years ago · Last pushed 7 months ago
Metadata Files
Readme License

README.md

UnitRangesSortedSets

Build Status Coverage

Sorted set of UnitRanges. Sorted in ascending order and no one range overlaps with another.

mutable struct UnitRangesSortedSet{K, TU} <: AbstractSet{TU}

UnitRangesSortedSet can be created like the standard Set:

julia UnitRangesSortedSet(somecontainer)

for example: ```julia julia> using UnitRangesSortedSets

julia> UnitRangesSortedSet((1, 2, 4)) UnitRangesSortedSet{Int64} with 2 elements: 1:2 4:4

julia> UnitRangesSortedSet(('a':'z', 'α':'ω')) UnitRangesSortedSet{Char} with 2 elements: 'a':'z' 'α':'ω'

julia> Random.seed!(1234);

julia> UnitRangesSortedSet(rand(1:20, 10)) UnitRangesSortedSet{Int64} with 6 elements: 5:5 7:8 10:11 15:16 18:18 20:20 ```

or with push!:

```julia julia> urs = UnitRangesSortedSet{Int}() UnitRangesSortedSet{Int64}()

julia> push!(urs, 1) UnitRangesSortedSet{Int64} with 1 element: 1:1

julia> push!(urs, 2) UnitRangesSortedSet{Int64} with 1 element: 1:2

julia> push!(urs, 10:12) UnitRangesSortedSet{Int64} with 2 elements: 1:2 10:12 ```

Iterating over set of ranges:

```julia julia> for r in urs @show(r) end r = 1:2 r = 10:12

julia> for r in urs, i in r @show(i) end i = 1 i = 2 i = 10 i = 11 i = 12

julia> for i in Iterators.flatten(urs) @show(i) end i = 1 i = 2 i = 10 i = 11 i = 12

julia> collect(urs) 2-element Vector{UnitRange{Int64}}: 1:2 10:12 ```

Deleting elements and ranges: ```julia julia> delete!(urs, 10:11) UnitRangesSortedSet{Int64} with 2 elements: 1:2 12:12

julia> delete!(urs, 1) UnitRangesSortedSet{Int64} with 2 elements: 2:2 12:12 ```

SubSet

It is possible to create the subset of UnitRangesSortedSet, like a view for Arrays: ```julia julia> urs = UnitRangesSortedSet((1:2, 10:12)) UnitRangesSortedSet{Int64} with 2 elements: 1:2 10:12

julia> ss = subset(urs, 0:10) 2-element subset(UnitRangesSortedSet{Int64}, DataStructures.Tokens.IntSemiToken(3):DataStructures.Tokens.IntSemiToken(4)): 1:2 10:10 ```

The subset object is an static, iterable view of the container.

Two types of UnitRangesSortedSet

The first type UnitRangesSortedSet{K} contains SortedDict{K,K}, julia mutable struct UnitRangesSortedSet{K,TU} <: AbstractUnitRangesSortedContainer{K,TU} ranges::SortedDict{K,K,FOrd} end where each element of the dict contains the first(range) as key, and the last(range) as value.

The second implementation VecUnitRangesSortedSet{K} is based on Vector{K}s: julia mutable struct VecUnitRangesSortedSet{K,TU} <: AbstractUnitRangesSortedContainer{K,TU} rstarts::Vector{K} rstops::Vector{K} end where rstarts::Vector{K} and rstops::Vector{K} are the starts and stops of the ranges respectively.

These two implementations have a similar API but different speeds.

In either case, both of them can be converted to each other using the appropriate constructor.

Benchmarking

All results of benchmarks in the file test-bench-results.md.

Main conclusions of benchmarking: * in any case of iterating over ranges or consecutively element-wise in any AbstractUnitRangesSortedSet is much much faster then in any another variant. * element-wise iterating, and over ranges iterating, in VecUnitRangesSortedSet is faster by the orders over UnitRangesSortedSet. * when created from elements in random order, UnitRangesSortedSet is vastly superior to the Vec variant. * creating in consecutively element-wise order, VecUnitRangesSortedSet is an order of magnitude faster than creating a set of the second type. * in searching operations (in(), subset()) VecUnitRangesSortedSet variant is faster: in Julia-v1.6 it is twice as fast, in Julia-1.8 the speedup is about 20-30%. * if your range diapason is about some millions of elements then the BitSet is the best choice for creating. And then convert(UnitRangesSortedSet, someBitSetContainer) is the solution to have the fast iteration over container.

Note

For Char, StepRange{Char,UInt8} will be used, with a step of oneunit(UInt8) if needed.

Owner

  • Name: Denis Telnov
  • Login: denius
  • Kind: user
  • Location: Saint Petersburg, Russia

GitHub Events

Total
  • Issue comment event: 1
  • Push event: 1
  • Create event: 1
  • Commit comment event: 1
Last Year
  • Issue comment event: 1
  • Push event: 1
  • Create event: 1
  • Commit comment event: 1

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 2
  • Total pull requests: 3
  • Average time to close issues: about 18 hours
  • Average time to close pull requests: 15 minutes
  • Total issue authors: 2
  • Total pull request authors: 1
  • Average comments per issue: 3.5
  • Average comments per pull request: 1.0
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • mnemnion (1)
  • JuliaTagBot (1)
Pull Request Authors
  • denius (3)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads: unknown
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 4
juliahub.com: UnitRangesSortedSets

Sorted set of unit ranges.

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 0 Total
Rankings
Dependent repos count: 9.9%
Dependent packages count: 38.9%
Average: 43.9%
Forks count: 53.5%
Stargazers count: 73.2%
Last synced: 6 months ago

Dependencies

.github/workflows/CI.yml actions
  • actions/checkout v2 composite
  • codecov/codecov-action v3 composite
  • julia-actions/cache v1 composite
  • julia-actions/julia-buildpkg v1 composite
  • julia-actions/julia-processcoverage v1 composite
  • julia-actions/julia-runtest v1 composite
  • julia-actions/setup-julia v1 composite
.github/workflows/TagBot.yml actions
  • JuliaRegistries/TagBot v1 composite
.github/workflows/register.yml actions
  • julia-actions/RegisterAction latest composite
.github/workflows/CompatHelper.yml actions