Class: Yk::EMMap

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

Overview

EMMaps are associative containers with external iterators that store elements formed by a combination of a key and a value, following a specific order, and where multiple elements can have equivalent keys. For use, 'Yk/ESet';include Yk;

Defined Under Namespace

Classes: Iterator

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|key| ... } ⇒ EMMap

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

Yield Parameters:

  • key (Object)

    object pointed by an element.

Yield Returns:

  • (Object)

    should be comparable with method, '<'.



320
321
# File 'for_yard_product.rb', line 320

def initialize
end

Class Method Details

.find(first, last, obj = nil) {|obj| ... } ⇒ EMMap::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:

  • (EMMap::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



373
374
# File 'for_yard_product.rb', line 373

def EMMap.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.



381
382
# File 'for_yard_product.rb', line 381

def EMMap.for_each first, last
end

Instance Method Details

#beginEMMap::Iterator

Return iterator to beginning

Returns:



323
324
# File 'for_yard_product.rb', line 323

def begin
end

#clearObject

Clear content



332
333
# File 'for_yard_product.rb', line 332

def clear
end

#endEMMap::Iterator

Return iterator to end

Returns:



326
327
# File 'for_yard_product.rb', line 326

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



360
361
# File 'for_yard_product.rb', line 360

def erase first, last
end

#insert(position, key, value) ⇒ EMMap::Iterator #insert(key, value) ⇒ EMMap::Iterator

Overloads:

  • #insert(position, key, value) ⇒ EMMap::Iterator

    Insert element with an object using a hint

    Parameters:

    • position (EMMap::Iterator)

      Hint for the position where the element can be inserted.

    • key (Object)

      key object to be pointed by the inserted elements.

    • value (Object)

      value object to be pointed by the inserted elements.

    Returns:

    • (EMMap::Iterator)

      An iterator pointing to either the newly inserted element.

  • #insert(key, value) ⇒ EMMap::Iterator

    Insert element with an object

    Parameters:

    • key (Object)

      key object to be pointed by the inserted elements.

    • value (Object)

      value object to be pointed by the inserted elements.

    Returns:

    • (EMMap::Iterator)

      An iterator pointing to either the newly inserted element.



351
352
# File 'for_yard_product.rb', line 351

def insert *args
end

#lower_boundEMMap::Iterator

Return iterator to lower bound

Returns:



338
339
# File 'for_yard_product.rb', line 338

def lower_bound 
end

#sizeInteger

Return container size

Returns:

  • (Integer)

    Return container size



329
330
# File 'for_yard_product.rb', line 329

def size
end

#upper_boundEMMap::Iterator

Return iterator to upper bound

Returns:



335
336
# File 'for_yard_product.rb', line 335

def upper_bound
end