https://github.com/tsukasaoishi/figure_set
FigureSet is the library which treats set operation.
https://github.com/tsukasaoishi/figure_set
ruby set
Last synced: 8 months ago
JSON representation
FigureSet is the library which treats set operation.
- Host: GitHub
- URL: https://github.com/tsukasaoishi/figure_set
- Owner: tsukasaoishi
- License: mit
- Created: 2012-11-26T14:29:32.000Z (over 13 years ago)
- Default Branch: main
- Last Pushed: 2023-03-17T08:08:09.000Z (over 3 years ago)
- Last Synced: 2025-01-31T18:14:27.390Z (over 1 year ago)
- Topics: ruby, set
- Language: C
- Size: 40 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.rdoc
- Changelog: History.txt
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
= FigureSet
{
}[http://badge.fury.io/rb/figure_set] {
}[https://travis-ci.org/tsukasaoishi/figure_set] {
}[https://codeclimate.com/github/tsukasaoishi/figure_set]
= Description
FigureSet is the library which treats set operation.
FigureSet is able to treat the set of 32bit integer.(0 .. 2 ** 32 -1)
= How to
== Initialize
=== an empty set.
empty_set = FigureSet.new
=== give array.
set = FigureSet.new([0,3,6,7])
== Element operation
=== add to set.
set = FigureSet.new
set.add 10
set << 100
set.to_a #=> [10, 100]
=== remove from set.
set = FigureSet.new([1,4,5])
set.delete(4)
set.to_a #=> [1, 5]
== Set operation
=== and
set1 = FigureSet.new([1,2,3,5])
set2 = FigureSet.new([2,4,6])
set_and = set1 & set2
set_and.to_a #=> [2]
=== or
set1 = FigureSet.new([1,2,3,5])
set2 = FigureSet.new([2,4,6])
set_or = set1 | set2
set_or.to_a #=> [1,2,3,4,5,6]
== Other
=== size
set = FigureSet.new([1,2,3])
set.size #=> 3
=== empty?
set = FigureSet.new
set.empty? #=> true
=== clear
set = FigureSet.new([1,2,3])
set.clear
set.to_a #=> []
= INSTALL:
sudo gem install figure_set
= LICENSE:
FigureSet is released under the MIT license.