/ LJCPHPCodeDoc / LJCCollectionLib / LJCCollectionBase


Syntax

PHP
class LJCCollectionBase

Represents a Collection of objects.

Remarks

The LJCCollectionBase class provides the code that can be inherited to create a strongly typed Collection.

It accomplishes this by implementing IteratorAggregate which provides "foreach" functionality and Countable which provides "count" functionality.

A strongly typed collection class would extend (inherit) from this base class and include an AddObject() method that would require the strongly typed object collection item. This is what makes the collection strongly typed.

The strongly typed collection class would also provide a Retrieve() method that could retrieve the internal array element by key.

For an example of how this works, see class: LJCDBAccessLib-LJCDbColumns. Use this code to include the Collection lib classes.

Public Functions
Data Methods
AddItem Adds an object and key value.
ClearItems Clears the collection items.
DeleteItem Remove the item by Key value.
RetrieveItem Retrieves the item by Key value.
RetrieveItemAtIndex Retrieves the item by index.
Other Methods
GetKeys Gets an indexed array of keys.
GetValues Gets an indexed array of objects.
HasKey Indicates if a key already exists.
count Enables count(object).
getIterator Enables foreach().
10 Functions

Public Properties
$Item The elements array.

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.