🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

tree_map

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tree_map

1.0.5
Rubygems
Version published
Maintainers
1
Created
Source

tree_map

This is an AVL tree based implementation of Java's java.util.TreeMap structure.

It implements Java's java.util.NavigableMap interface.

learn a lot from treemap

References:

Install

gem install tree_map

Usage

In IRB (some lines elided):

irb(main):001:0> require 'treemap'
=> true
irb(main):002:0> m = TreeMap.new; nil
=> nil
irb(main):003:0> m.put(1, "foo")
=> nil
irb(main):004:0> m.put(100, "baz")
=> nil
irb(main):005:0> m.put(10, "bar")
=> nil
irb(main):006:0> m.each {|k, v| puts "#{k} -> #{v}" }
1 -> foo
10 -> bar
100 -> baz
=> nil
irb(main):007:0> m.to_a
=> [[1, "foo"], [10, "bar"], [100, "baz"]]
irb(main):008:0> m.keys
=> #<Set: {1, 10, 100}>
irb(main):009:0> m.values
=> ["foo", "bar", "baz"]
irb(main):010:0> m.first_key
=> 1
irb(main):011:0> m.last_key
=> 100
irb(main):012:0> m.lower_key(10)
=> 1
irb(main):013:0> m.floor_key(10)
=> 10
irb(main):014:0> m.ceiling_key(10)
=> 10
irb(main):015:0> m.higher_key(10)
=> 100

Run Tests:

rake

OR

rake test

FAQs

Package last updated on 22 Mar 2022

Did you know?

Socket

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.

Install

Related posts