Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/titsuki/raku-algorithm-binaryindexedtree
data structure for cumulative frequency tables
https://github.com/titsuki/raku-algorithm-binaryindexedtree
Last synced: 3 months ago
JSON representation
data structure for cumulative frequency tables
- Host: GitHub
- URL: https://github.com/titsuki/raku-algorithm-binaryindexedtree
- Owner: titsuki
- License: artistic-2.0
- Created: 2016-02-11T13:31:36.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-08-08T12:48:57.000Z (5 months ago)
- Last Synced: 2024-08-09T15:42:15.141Z (5 months ago)
- Language: Raku
- Size: 21.5 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
- License: LICENSE
Awesome Lists containing this project
README
[![Actions Status](https://github.com/titsuki/raku-Algorithm-BinaryIndexedTree/workflows/test/badge.svg)](https://github.com/titsuki/raku-Algorithm-BinaryIndexedTree/actions)
NAME
====Algorithm::BinaryIndexedTree - data structure for cumulative frequency tables
SYNOPSIS
========use Algorithm::BinaryIndexedTree;
my $BIT = Algorithm::BinaryIndexedTree.new();
$BIT.add(5,10);
$BIT.get(0).say; # 0
$BIT.get(5).say; # 10
$BIT.sum(4).say; # 0
$BIT.sum(5).say; # 10$BIT.add(0,10);
$BIT.sum(5).say; # 20DESCRIPTION
===========Algorithm::BinaryIndexedTree is the data structure for maintainig the cumulative frequencies.
CONSTRUCTOR
-----------### new
my $BIT = Algorithm::BinaryIndexedTree.new(%options);
#### OPTIONS
* `size => $size`
Sets table size. Default is 1000.
METHODS
-------### add
$BIT.add($index, $value);
Adds given value to the index `$index`.
### sum
my $sum = $BIT.sum($index);
Returns sum of the values of items from index 0 to index `$index` inclusive.
### get
my $value = $BIT.get($index);
Returns the value at index `$index`.
AUTHOR
======titsuki
COPYRIGHT AND LICENSE
=====================Copyright 2016 titsuki
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.
The algorithm is from Fenwick, Peter M. "A new data structure for cumulative frequency tables." Software: Practice and Experience 24.3 (1994): 327-336.