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, '<'.



111
112
# File 'for_yard_product.rb', line 111

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



162
163
# File 'for_yard_product.rb', line 162

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.



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

def EMSet.for_each first, last
end

Instance Method Details

#beginEMSet::Iterator

Return iterator to beginning

Returns:



114
115
# File 'for_yard_product.rb', line 114

def begin
end

#clearObject

Clear content



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

def clear
end

#endEMSet::Iterator

Return iterator to end

Returns:



117
118
# File 'for_yard_product.rb', line 117

def end
end

#erase(first, last) ⇒ Object

Removes from the set container a range of elements ([first,last)). 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



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

def erase first, last
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.



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

def insert *args
end

#lower_boundEMSet::Iterator

Return iterator to lower bound

Returns:



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

def lower_bound 
end

#sizeInteger

Return container size

Returns:

  • (Integer)

    Return container size



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

def size
end

#upper_boundEMSet::Iterator

Return iterator to upper bound

Returns:



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

def upper_bound
end