Skip to content

Latest commit

 

History

History
204 lines (160 loc) · 5.86 KB

AsitSummary.md

File metadata and controls

204 lines (160 loc) · 5.86 KB

Asit/Asmit Summary

  • implements the PkeyInterface

Class Asit

  • Extends It
  • implements assoc array collection element get-/set-methods

The assoc element array key is used as (unique) primary key. A primary key may be replaced by another (unique) key.

Class Asmit

  • extends Asit
  • accepts multiple (assoc) (unique) primary keys for (each) collection element

Collection elements are searchable using

  • Iterator (et al.) methods
  • primary key(s)

For non-assoc arrays,

  • primary key is the (numeric) array index

Asit example:

use Kigkonsult\Asit\Asit;
class MyClass extend Asit {}
$myClass = MyClass::factory();
...
$myClass->append( $element, $pKey );
...

The Asit class is extended by :

  • Asittag, secondary keys, additional (non-unique) tags (aka attributes?) may be set for each element
  • AsitList, assert collection elements of expected valueType

The Asmit class is extended by :

  • Asmittag, secondary keys, additional (non-unique) tags (aka attributes?) may be set for each element
  • AsmitList, assert collection elements of expected valueType

Inherited methods

Inherit methods from It

Primary key methods

Asit::assertPkey( pKey )

  • Assert primary key, int and string allowed
  • pKey mixed
  • Return void
  • Throws PkeyException
  • Static

Asit::pKeyExists( pKey )

  • pKey int|string
  • Return bool true if primary key is set

Asmit::countPkeys( pKey )

  • Return count of primary keys for collection element
  • Asmit only
  • pKey int|string
  • Throws PkeyException
  • Return int

Asit::getPkeys( [ sortFlag ] )

  • sortFlag int default SORT_REGULAR
  • Return array all primary keys

Asit::getCurrentPkey()

  • Return primary key for current
  • Return int|string
  • Throws PositionException

Asmit::removePkey( pKey )

  • Asmit only
  • Remove primary key for collection element but not last
  • pKey int|string
  • Throws PkeyException
  • Return int

Get methods

Asit::pKeyFetch( pKey )

  • Return element for a primary key
  • pKey int|string
  • Return mixed
  • Throws PkeyException

Asit::get( [ pKeys [, sortParam ]] )

  • Return (non-assoc) array of element(s) in collection, using the opt. primary keys for selection.
  • pKeys int|string|array
  • sortParam int|callable asort sort_flags or uasort callable, null=>ksort
  • Return array
  • Throws SortException

Asit::pKeyYield()

  • Implements Generators yield functionality, Return collection [ pKey => ] element
  • A memory minimizer for use in foreach-loops, replaces get(), getIterator() etc
  • Return mixed

Asit::pKeyGet( pKeys [, sortParam ] )

  • Return (non-assoc array) sub-set of element(s) in collection using primary keys
  • Convenient get method alias
  • pKeys int|string|array
  • sortParam int|callable asort sort_flags or uasort callable, null=>ksort
  • Return array
  • Throws SortException

Set methods

Asit::append( element [, pKey ] )

  • Append element to (array) collection, opt with primary key (pKey)
  • Note, last appended element is always current
  • element mixed
  • pKey int|string MUST be unique
  • Return static
  • Throws PkeyException

Asit::setCollection( collection )

  • Set collection using array key as primary key
  • Multiple setCollections allowed, i.e. batch appends
    • note, unique primary keys
  • collection array / Traversable
  • Return static
  • Throws CollectionException, PkeyException

Asit::replacePkey( oldPkey, newPkey )

  • Replace (set) primary key for collection element
  • oldPkey int|string
  • newPkey int|string
  • Return static
  • Throws PkeyException

Asit::setCurrentPkey( pKey )

  • Asit : alter primary key for current element
  • Asmit : add primary key for current element
  • To be used in parallel with the Iterator current method, below
  • pKey int|string
  • Return static
  • Throws PositionException, PkeyException

Asmit::addCurrentPkey( pKey )

  • Asmit : add primary key for current element
  • To be used in parallel with the Iterator current method, below
  • pKey int|string
  • Return static
  • Throws PositionException, PkeyException

Current element primary key methods summary

Asit::getCurrentPkey()

  • Return primary key for current
  • Throws PositionException

Asmit::getCurrentPkey()

  • Return first found primary key for current
  • Throws PositionException

Asmit::getCurrentPkeys()

  • Return primary keys for current
  • Throws PositionException

Asit::setCurrentPkey( pKey )

  • Asit : alter primary key for current element
  • Return static
  • Throws PkeyException, PositionException

Asmit::addCurrentPkey( pKey )

  • Asmit : add primary key for current element
  • Return static
  • Throws PkeyException, PositionException

Asit::append( element, pKey )

  • Append element to (array) collection, opt with primary key (pKey)
  • Note, last appended element is always current
  • Return static
  • Throws PkeyException

Asit::pKeySeek( pKey )

  • Seeks to a given position in the iterator using primary key
  • pKey int|string
  • Return static
  • Throws PkeyException

Iterator et al. related methods

Asit::getPkeyIterator()

  • Return an external iterator ( pKey => element )
  • For Asmit and in case of multiple primary keys for element, first found is used
  • Return Traversable

Go to README - It summary - Asittag/Asmittag summary - AsitList/AsmitList summary