Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
fingertree
Advanced tools
Readme
Implementation of Finger Tree, an immutable general-purpose data structure which can further be used to implement random-access sequences, priority-queues, ordered sequences, interval trees, etc.
Based on: Ralf Hinze and Ross Paterson, "Finger trees: a simple general-purpose data structure".
Note that Finger Tree is not meant to be used on its own. Instead, it should serve as an infrastructure for building other data structures. As an example, immutable-sequence.js is an immutable random-access sequence implementation built on top of this library.
Download the js file and include it in your web page.
<script type="text/javascript" src="./fingertree.js"></script>
If you want to use it in Node.js, you may install it via npm.
npm install fingertree
Then, in your program:
var FingerTree = require('fingertree');
// Create a finger-tree from an array
// By default, the tree is annotated with a size measurer.
var tree = FingerTree.fromArray([1, 2, 3, 4]);
tree.measure(); // 4
tree.peekFirst(); // 1
tree.peekLast(); // 4
// Create a new tree with an element added to the front
var tree2 = tree.addFirst(0);
tree2.peekFirst(); // 0
// Create a new tree with an element added to the end
var tree3 = tree.addLast(5);
tree3.peekLast(); // 5
// Create a new tree with the first element removed
var tree4 = tree.removeFirst();
tree4.peekFirst(); // 2
// Create a new tree with the last element removed
var tree5 = tree.removeLast();
tree5.peekLast(); // 3
// Split into two trees with a predicate on measure.
var split = tree.split(function (measure) {
return measure > 3;
});
split[0].measure(); // 3
split[1].measure(); // 1
// Create a finger-tree with a custom measurer.
var measurer = {
identity: function () {
return -Infinity;
},
measure: function (x) {
return x;
},
sum: function (a, b) {
return Math.max(a, b);
}
};
var maxTree = FingerTree.fromArray([1, 3, 2, 9, 7], measurer);
maxTree.measure(); // 9
© 2014 Xueqiao Xu <xueqiaoxu@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Finger Tree data structure
The npm package fingertree receives a total of 12 weekly downloads. As such, fingertree popularity was classified as not popular.
We found that fingertree demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.