Class: Yk::EMSet

Inherits:
Object
  • Object
show all
Defined in:
for_yard_product.rb

Overview

EMSets are containers with external iterators that store elements following a specific order, and where multiple elements can have equivalent values. For use, require 'Yk/ESet';include Yk;

Defined Under Namespace

Classes: Iterator

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|obj| ... } ⇒ EMSet

initlialize with a block which returns comparing basis like Enumerable::sort_by, however using <, not <=>.

Yield Parameters:

  • obj (Object)

    object pointed by an element.

Yield Returns:

  • (Object)

    should be comparable with method, '<'.



121
122
# File 'for_yard_product.rb', line 121

def initialize
end

Class Method Details

.find(first, last, obj = nil) {|obj| ... } ⇒ EMSet::Iterator

Searches the container for an element with an object equivalent to the third argument and/or validated with the provided block in a range of elements ([first,last)), 'obj' and returns an iterator to it if found, otherwise it returns an iterator to .

Parameters:

Yield Parameters:

  • obj (Object)

    object argument pointed by an element passed for validation with the block

Yield Returns:

  • (Object)

    validation result from the block

Returns:

  • (EMSet::Iterator)

    iterator pointing the element with equivalent object.

Raises:

  • ArgumentError raised when an argument is not a compatible iterator.

  • ArgumentError raised when first and last iterators are not from the same container.

  • ArgumentError raised when neither parameter, obj nor block is provided.

  • RangeError raised when dereferencing end iterator



182
183
# File 'for_yard_product.rb', line 182

def EMSet.find first, last, obj = nil
end

.for_each(first, last) {|obj| ... } ⇒ Object

Applies given block to each of the elements in the range [first,last).

Parameters:

Yield Parameters:

  • obj (Object)

    object in an element

Raises:

  • ArgumentError raised when an argument is not a compatible iterator.

  • ArgumentError raised when first and last iterators are not from the same container.



190
191
# File 'for_yard_product.rb', line 190

def EMSet.for_each first, last
end

Instance Method Details

#beginEMSet::Iterator

Return iterator to beginning

Returns:



124
125
# File 'for_yard_product.rb', line 124

def begin
end

#clearObject

Clear content



133
134
# File 'for_yard_product.rb', line 133

def clear
end

#endEMSet::Iterator

Return iterator to end

Returns:



127
128
# File 'for_yard_product.rb', line 127

def end
end

#erase(position) ⇒ Object #erase(frist, last) ⇒ Object

Overloads:

  • #erase(position) ⇒ Object

    Removes an element

    Parameters:

    Raises:

    • ArgumentError raised when an argument is not a compatible iterator.

  • #erase(frist, last) ⇒ Object

    Removes a range of elements ([first,last)) from the container. Iterators specifying a range within the set container to be removed: [first,last). i.e., the range includes all the elements between first and last, including the element pointed by first but not the one pointed by last.

    Parameters:

    Raises:

    • ArgumentError raised when an argument is not a compatible iterator.

    • ArgumentError raised when first and last iterators are not from the same container.

    • RangeError raised when erasing end iterator



164
165
# File 'for_yard_product.rb', line 164

def erase *args
end

#find(arg) ⇒ EMSet::Iterator

Searches the container for an element with an object equivalent to the argument.

Parameters:

  • arg (Object)

    to search equivalency.

Returns:

  • (EMSet::Iterator)

    iterator pointing the element with equivalent object.



169
170
# File 'for_yard_product.rb', line 169

def find arg
end

#insert(position, obj) ⇒ EMSet::Iterator #insert(obj) ⇒ EMSet::Iterator

Overloads:

  • #insert(position, obj) ⇒ EMSet::Iterator

    Insert element with an object using a hint

    Parameters:

    • position (EMSet::Iterator)

      Hint for the position where the element can be inserted.

    • obj (Object)

      Object to be pointed by the inserted elements.

    Returns:

    • (EMSet::Iterator)

      An iterator pointing to either the newly inserted element.

  • #insert(obj) ⇒ EMSet::Iterator

    Insert element with an object

    Parameters:

    • obj (Object)

      key object to be pointed by the inserted elements.

    Returns:

    • (EMSet::Iterator)

      An iterator pointing to either the newly inserted element.



150
151
# File 'for_yard_product.rb', line 150

def insert *args
end

#lower_boundEMSet::Iterator

Return iterator to lower bound

Returns:



139
140
# File 'for_yard_product.rb', line 139

def lower_bound 
end

#sizeInteger

Return container size

Returns:

  • (Integer)

    Return container size



130
131
# File 'for_yard_product.rb', line 130

def size
end

#upper_boundEMSet::Iterator

Return iterator to upper bound

Returns:



136
137
# File 'for_yard_product.rb', line 136

def upper_bound
end