Class DataMapper::OrderedSet
In: lib/dm-core/support/ordered_set.rb
Parent: Object

An ordered set of things

{OrderedSet} implements set behavior and keeps track of the order in which entries were added.

{OrderedSet} allows to inject a class that implements {OrderedSet::Cache::API} at construction time, and will use that cache implementation to enforce set semantics and perform internal caching of insertion order.

@see OrderedSet::Cache::API @see OrderedSet::Cache @see SubjectSet::NameCache

@api private

Methods

<<   []   clear   delete   each   empty?   include?   index   initialize_copy   merge   new   size   to_ary  

Included Modules

Enumerable

Classes and Modules

Class DataMapper::OrderedSet::Cache

Attributes

entries  [R]  This set‘s entries

The order in this Array is not guaranteed to be the order in which the entries were inserted. Use each to access the entries in insertion order.

@return [Array]

 this set's entries

@api private

Public Class methods

Initialize an OrderedSet

@param [each] entries

  the entries to initialize this set with

@param [Class<Cache::API>] cache

  the cache implementation to use

@api private

Public Instance methods

Add or update an entry in the set

If the entry to add isn‘t part of the set already, it will be added. If an entry with the same cache key as the entry to add is part of the set already, it will be replaced with the given entry.

@param [Object] entry

  the entry to be added

@return [OrderedSet] self

@api private

Get the entry at the given index

@param [Integer] index

  the index of the desired entry

@return [Object, nil]

  the entry at the given index, or nil if no entry is present

@api private

Removes all entries and returns self

@return [OrderedSet] self

@api private

Delete an entry from this OrderedSet

@param [Object] entry

  the entry to delete

@return [Object, nil]

  the deleted entry or nil

@api private

Iterate over each entry in the set

@yield [entry]

  all entries in the set

@yieldparam [Object] entry

  an entry in the set

@return [OrderedSet] self

@api private

Check if there are any entries

@return [Boolean]

  true if the set is empty

@api private

Check if the entry exists in the set

@param [Object] entry

  the entry to test for

@return [Boolean]

  true if entry is included in the set

@api private

Return the index for the entry in the set

@param [Object] entry

  the entry to check the set for

@return [Integer, nil]

  the index for the entry, or nil if it does not exist

@api private

Initialize a copy of OrderedSet

@api private

Merge with another Enumerable object

@param [each] other

  the Enumerable to merge with this OrderedSet

@return [OrderedSet] self

@api private

The number of entries

@return [Integer]

  the number of entries

@api private

Convert the OrderedSet into an Array

@return [Array]

  an array containing all the OrderedSet's entries

@api private

[Validate]