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



445
446
# File 'for_yard_product.rb', line 445

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.

  • ArgumentError raised when using argument(s) with erased position

  • RangeError raised when dereferencing end iterator



525
526
# File 'for_yard_product.rb', line 525

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.

  • ArgumentError raised when using argument(s) with erased position



534
535
# File 'for_yard_product.rb', line 534

def EMMap.for_each first, last
end

Instance Method Details

#add(position, key, value) ⇒ True #add(key, value) ⇒ True

Overloads:

  • #add(position, key, value) ⇒ True

    Insert element with an object using a hint and return true if a new element was inserted or false if an equivalent element already existed. Do not return iterator object. More efficient if you do not need inserted position (removed by GC).

    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:

    • (True)

      Always return true.

  • #add(key, value) ⇒ True

    Insert element with an object and return true if a new element was inserted or false if an equivalent element already existed. Do not return iterator object. More efficient if you do not need inserted position (removed by GC).

    Parameters:

    • key (Object)

      key object to be pointed by the inserted elements.

    • value (Object)

      value object to be pointed by the inserted elements.

    Returns:

    • (True)

      Always return true.



489
490
# File 'for_yard_product.rb', line 489

def add *args
end

#beginEMMap::Iterator

Return iterator to beginning

Returns:



448
449
# File 'for_yard_product.rb', line 448

def begin
end

#clearObject

Clear content



457
458
# File 'for_yard_product.rb', line 457

def clear
end

#endEMMap::Iterator

Return iterator to end

Returns:



451
452
# File 'for_yard_product.rb', line 451

def end
end

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

Overloads:

  • #erase(position) ⇒ Object

    Erase an element from the container

    Parameters:

    Raises:

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

    • ArgumentError raised when using argument with erased position

  • #erase(frist, last) ⇒ Object

    Erase 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

    • ArgumentError raised when use argument with erased position



505
506
# File 'for_yard_product.rb', line 505

def erase *args
end

#find(arg) ⇒ EMMap::Iterator

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

Parameters:

  • arg (Object)

    to search equivalency.

Returns:

  • (EMMap::Iterator)

    iterator pointing the element with equivalent object.

Raises:

  • ArgumentError raised when using argument(s) with erased position



511
512
# File 'for_yard_product.rb', line 511

def find arg
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 and return new iterator object

    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 and return new iterator 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.



476
477
# File 'for_yard_product.rb', line 476

def insert *args
end

#lower_boundEMMap::Iterator

Return iterator to lower bound

Returns:



463
464
# File 'for_yard_product.rb', line 463

def lower_bound 
end

#sizeInteger

Return container size

Returns:

  • (Integer)

    Return container size



454
455
# File 'for_yard_product.rb', line 454

def size
end

#upper_boundEMMap::Iterator

Return iterator to upper bound

Returns:



460
461
# File 'for_yard_product.rb', line 460

def upper_bound
end