PHP Classes

File: docs/AsitSummary.md

Recommend this page to a friend!
  Classes of Kjell-Inge Gustafsson   Asit PHP Collection Class   docs/AsitSummary.md   Download  
File: docs/AsitSummary.md
Role: Auxiliary data
Content type: text/markdown
Description: Auxiliary data
Class: Asit PHP Collection Class
Manages collections of elements stored in arrays
Author: By
Last change: 1.4.10
Date: 3 years ago
Size: 5,366 bytes
 

Contents

Class file image Download

[comment]: # (This file is part of Asit, manages array collections. Copyright 2020 Kjell-Inge Gustafsson, kigkonsult, All rights reserved, licence LGPL 3.0)

Asit/Asmit Summary

>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 (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 class extends : * [Asittag], secondary keys, additional (non-unique) tags (aka attributes?) may be set for each element * [AsitList], assert collection elements of expected valueType

Asmit class extends : * [Asmittag], secondary keys, additional (non-unique) tags (aka attributes?) may be set for each element * [AsmitList], assert collection elements of expected valueType

Inherited methods

Inherited methods from [It]

Primary key methods

* Assert primary key, int and string allowed
* ```pKey``` _mixed_
* Return void
* Throws PkeyException
* Static

  • 
    
  • Return _bool_ true if primary key is set
* Return count of primary keys for collection element
* ```Asmit``` only
* ```pKey``` _int_|_string_
* Throws PkeyException
* Return _int_

  • 
    
  • Return _array_ all primary keys
* Return primary key for ```current```
* ```firstFound``` _bool_ ```Asmit``` only, one (firstFound=true, default) or (array) all
* Return _int_|_string_|_array_
* Throws RuntimeException

  • 
    
  • Remove primary key for collection element but not last
  • Throws PkeyException
  • Return _int_

Get-methods

* 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
* Return _array_
* Throws SortException

  • Return (non-assoc array) sub-set of element(s) in collection using primary keys
  • Convenient ```get``` method alias
  • 
    
  • Return _array_
  • Throws SortException

Set methods

* 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
    
  • Set collection using array key as primary key
  • Multiple setCollections allowed, i.e. batch appends * note, unique primary keys
  • 
    
  • Return _static_
  • Throws CollectionException, PkeyException
* Replace (set) primary key for collection element
* ```oldPkey``` _int_|_string_
* ```newPkey``` _int_|_string_
* Return _static_
* Throws PkeyException

  • 
    
  • To be used in parallel with the Iterator ```current``` method, below
  • 
    
  • Return _static_
  • Throws RuntimeException, PkeyException
* ```Asmit``` : add primary key for ```current``` element
* To be used in parallel with the Iterator ```current``` method, below
* ```pKey``` _int_|_string_
* Return _static_
* Throws RuntimeException, PkeyException

#### Current element primary key methods summary

  • Return primary key for ```current```
  • Throws RuntimeException
* ```Asit``` : alter primary key for ```current``` element
* Throws PkeyException, RuntimeException

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

  • Seeks to a given position in the iterator using primary key
  • Throws PkeyException

Iterator et al. related methods

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

  • Seeks to a given position in the iterator using primary key
  • 
    
  • Return _static_
  • Throws PkeyException

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

[It]:ItSummary.md [AsitList]:ListSummary.md [AsmitList]:ListSummary.md [Asittag]:AsittagSummary.md [Asmittag]:AsittagSummary.md [README]:../README.md