\Phabstractic\Data\Types\ResourceAbstractList

List Abstract Class - Defines a basic list class, implements ListInterface

A list can be several things: a stack, a queue, a ring buffer, etc. This abstract class implements the ListInterface and defines an internal list variable (list = array). Inherit from this class if you are building a list like class.

CHANGELOG

1.0: Created AbstractList - May 10th, 2013 2.0: Refactored and re-formatted for inclusion in primus - April 11th, 2015 3.0: eliminated dependency on configurationtrait, subs can implement reformatted for inclusion in phabstractic - July 21st, 2016

Summary

Methods
Properties
Constants
__construct()
top()
topReference()
push()
pushReference()
pop()
popReference()
index()
indexReference()
count()
isEmpty()
clear()
remove()
getList()
exchange()
duplicate()
roll()
No public properties found
No constants found
No protected methods found
$list
N/A
No private methods found
No private properties found
N/A

Properties

$list

$list : array

The internal list member

Generally an array, but can be overridden by a child class to be anything.

Type

array — The list data structure array

Methods

__construct()

__construct(mixed  $data = null) 

AbstractList Constructor

Populates the internal member array

Creates an empty list if no parameter given.

Parameters

mixed $data

The data to populate the internal member array

top()

top() : mixed|null

Retrieve the 'top' of the list (lifo, fifo, etc.)

Note: Does not 'pop' the value off the list

Returns

mixed|null —

'Top' Value of List, or null

topReference()

topReference() : mixed|null

Return the 'top' of the list as a reference

Note: Does not 'pop' the value off the list

Returns

mixed|null —

'Top' Values as Reference of List, or null

push()

push() : integer

Push a value on to the list (lifo, fifo, etc)

However that is in implementation (lifo/fifo/etc)

Returns

integer —

Count of new list

pushReference()

pushReference(  $a) : integer

Push a reference on to the list (fifo, lifo, etc)

However that is in implementation (lifo/fifo/etc)

Parameters

$a

Returns

integer —

Count of new list

pop()

pop() : mixed|null

Returns the 'top' value and pops the value off the list

However that is in implementation (lifo/fifo/etc)

Returns

mixed|null —

The 'top' value of the list, or null

popReference()

popReference() : mixed|null

Returns the 'top' value as reference, pops value off

However that is in implementation (lifo/fifo/etc)

Returns

mixed|null —

The 'top' value as reference of the list, or null

index()

index(integer  $i) : mixed

Return the $i'th element of the list

This should be used carefully, as implementation varies

Parameters

integer $i

The numerical index into the list

Throws

\RangeException

If index is out of well... range.

Returns

mixed —

The value found at index of list: list[index]

indexReference()

indexReference(integer  $i) : mixed

Return the $i'th element of the list as a reference

Parameters

integer $i

The numerical index into the list

Throws

\RangeException

If index is out of well... range.

Returns

mixed —

The value at the list's numerical index as a reference

count()

count() : integer

Return the size of the list

Returns

integer —

The number of elements in the list currently

isEmpty()

isEmpty() : boolean

Return whether the list is empty currently

Returns

boolean —

Whether ths list is empty or not

clear()

clear() : \Phabstractic\Data\Types\Resource\Phabstractic\Data\Types\Resource\AbstractList

Clear all the values from the list

Be careful!

Returns

\Phabstractic\Data\Types\Resource\Phabstractic\Data\Types\Resource\AbstractList —

For chaining

remove()

remove(mixed  $value) : \Phabstractic\Data\Types\Resource\Phabstractic\Data\Types\Resource\AbstractList

Remove a value out of the list

This is just in case we want to remove something out of order.

Only removes the first occurance of value

Parameters

mixed $value

The value to remove

Returns

\Phabstractic\Data\Types\Resource\Phabstractic\Data\Types\Resource\AbstractList —

For chaining

getList()

getList() : array

Retrieve the list element of the list

Implementation varies return value

Returns

array —

The current internal list member

exchange()

exchange() : \Phabstractic\Data\Types\Resource\Phabstractic\Data\Types\Resource\AbstractList

Exchange the two top elements of the list

Returns

\Phabstractic\Data\Types\Resource\Phabstractic\Data\Types\Resource\AbstractList —

For chaining

duplicate()

duplicate() : \Phabstractic\Data\Types\Resource\Phabstractic\Data\Types\Resource\AbstractList

Duplicate the value at the top of the list

Note: Adds the duplicate to the front of the list

Returns

\Phabstractic\Data\Types\Resource\Phabstractic\Data\Types\Resource\AbstractList —

For chaining

roll()

roll(integer  $i) 

'Rolls' the list like one might 'roll' a wheel.

Negative values roll the list the opposite direction positive values roll the list.

Note: Edits the list in place, does not return copy of list

EX:

12345 would become 34512

Parameters

integer $i

The amount to roll the list

Throws

\Phabstractic\Data\Types\Resource\Exception\InvalidArgumentException

if parameter isn't integer