Skip to content

geni/ordered_set

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OrderedSet

OrderSet is an class for storing sets of objects. Unlike a Set, it maintains the order of the objects, but unlike an Array, each object can only exist once, and checking for inclusion takes constant time.

Usage:

s = [1,3,2,3,4,3].to_ordered_set
s.to_a
# => [1,3,2,4]

t = OrderedSet.new([6,7,5,6,5])
t.to_a
# => [6,7,5]

(s + t).to_a
# => [1,3,2,4,6,7,5]

s << 5
s.to_a
# => [1,3,2,4,5]

s.delete(1)
s.to_a
# => [3,2,4,5]

Install:

sudo gem install ninjudd-deep_clonable -s http://gems.github.com
sudo gem install ninjudd-ordered_set -s http://gems.github.com

License:

Copyright © 2008 Justin Balthrop, Geni.com; Published under The MIT License, see LICENSE

About

Like Set except it maintains the order of objects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%