Skip to content

SplArrayQueue

teguhrianto22 edited this page Oct 3, 2016 · 5 revisions

The SplStack class provides the main functionalities of a stack implemented using a doubly linked list and the iterator mode is based on FIFO (First In First Out).

Namespace

O2System\Spl\Datastructures

Class

O2System\Spl\Datastructures\SplArrayQueue

Usage Example

use O2System\Spl\Datastructures\SplArrayQueue;

$vehicles = new SplArrayQueue();
$vehicles->push( 'Ferrari' );

Methods Reference

SplArrayQueue::__construct

O2System\Spl\Datastructures\SplArrayQueue class constructor.

see: http://php.net/manual/en/class.splqueue.php

Parameter
Parameter type Requirement Description
$queue array optional initial array
Return
Type Description
SplArrayQueue Returns an SplArrayQueue object on success.

Example

$vehicles = new SplArrayQueue ( [ 
                'Ferrari',
                'Porsche' 
            ] );

SplArrayQueue::isEmpty

Checks if the array storage is empty.

Return
Type Description
bool Returns TRUE if the array storage is empty.

Example

if( $vehicles->isEmpty() ) 
{
    // if the array storage is empty
}

SplArrayQueue::has

Checks if a value exists in the storage.

Parameter
Parameter type Requirement Description
$needle mixed optional The searched value
$strict bool optional If the third parameter strict is set to TRUE then the in_array() function will also check the types of the needle in the haystack
Return
Type Description
bool Returns TRUE if a value exists in the storage.

Example

if( $vehicles->has() ) 
{
    // if a value exists in the storage
}

SplArrayQueue::getArrayCopy

Creates a copy of the storage.

Return
Type Description
array Returns A copy of the storage.

Example

//contohnya