Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
= Ruby/RBTree
== Description
A RBTree is a sorted associative collection that is implemented with a Red-Black Tree. It maps keys to values like a Hash, but maintains its elements in ascending key order. The interface is the almost identical to that of Hash.
A Red-Black Tree is a kind of binary tree that automatically balances by itself when a node is inserted or deleted. Lookup, insertion, and deletion are performed in O(log N) time in the expected and worst cases. On the other hand, the average case complexity of lookup/insertion/deletion on a Hash is constant time. A Hash is usually faster than a RBTree where ordering is unimportant.
The elements of a RBTree are sorted using the <=> method of their keys or a Proc set by the readjust method. It means all keys should be comparable with each other or a Proc that takes two keys should return a negative integer, 0, or a positive integer as the first argument is less than, equal to, or greater than the second one.
RBTree also provides a few additional methods to take advantage of the ordering:
== Example
A RBTree cannot contain duplicate keys. Use MultiRBTree that is the parent class of RBTree to store duplicate keys.
require "rbtree"
rbtree = RBTree["c", 10, "a", 20] rbtree["b"] = 30 p rbtree["b"] # => 30 rbtree.each do |k, v| p [k, v] end # => ["a", 20] ["b", 30] ["c", 10]
mrbtree = MultiRBTree["c", 10, "a", 20, "e", 30, "a", 40] p mrbtree.lower_bound("b") # => ["c", 10] mrbtree.bound("a", "d") do |k, v| p [k, v] end # => ["a", 20] ["a", 40] ["c", 10]
Note: a RBTree cannot be modified during iteration.
== Installation
Run the following command.
$ sudo gem install rbtree
== Changes === 0.4.6
=== 0.4.5
=== 0.4.4
=== 0.4.3
== License
MIT License. Copyright (c) 2002-2013 OZAWA Takuma.
dict.c and dict.h are modified copies that are originally in Kazlib 1.20 written by Kaz Kylheku. Its license is similar to the MIT license. See dict.c and dict.h for the details. The web page of Kazlib is at http://www.kylheku.com/~kaz/kazlib.html.
FAQs
Unknown package
We found that rbtree 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.