Project

YkESet

0.0
No commit activity in last 3 years
No release in over 3 years
Set/Map with external iterator, formerly ESet
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

ESet

Set/Map with external iterator

Installation

Add this line to your application's Gemfile:

gem 'YkESet'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install YkESet

Usage

require 'Yk/ESet'
include Yk


class Foo
    attr :f  
    def initialize f  
	    @f = f  
    end  
end  

s = ESet.new do |o|  
    o.f  
end  

# add method does not return iterator object (much efficient)
s.add Foo.new(rand)  
s.add Foo.new(rand)  
s.add Foo.new(rand)  
s.add Foo.new(rand)  

y = rand
result = s.add Foo.new(y)  
p result # true
result = s.add Foo.new(y)  
p result # false

ESet.for_each s.begin, s.end do |foo|  
    p foo.f  
end  

# insert method returns iterator object
it, result = s.insert Foo.new(y = rand)
p result # true
it, result = s.insert Foo.new(y)
p result # false

s.erase it
p it.erased? # true
begin
    s.erase it # wrongly erase twice
rescue ArgumentError
	p $! 
end

it = s.begin  
while !it.end?
    p it.item  
    it.inc  
end

begin
    it.item # already reached the end
rescue RangeError
    p $!
end    

# iterator is not value type but object type
jt = it
it.dec
p it == jt #true
jt = it.clone
jt.dec
p it != jt #true

See Document page

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/eset. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

Code of Conduct

Everyone interacting in the ESet project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.