Overview

Namespaces

  • BN
    • Collections
    • Compiler
      • Grammar
      • Parser
        • Operator
        • Token
      • Postfix
        • Operands
        • Operator
        • Token
      • Scanner
        • Converter
      • Token
  • Demo
  • None

Classes

  • LinearDataStructure
  • Queue
  • Stack

Exceptions

  • NullArgumentException
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * BN-PHP (https://bitbucket.org/zdenekdrahos/bn-php)
 4:  * @license New BSD License
 5:  * @author Zdenek Drahos
 6:  */
 7: 
 8: namespace BN\Collections;
 9: 
10: /**
11:  * Abstract parent class of all linear data structures (queue, stack or
12:  * object array). It defines basic methods clear, isEmpty, size and protected
13:  * array for data stored in data structure.
14:  */
15: abstract class LinearDataStructure
16: {
17:     /** @var array */
18:     protected $data = array();
19: 
20:     /**
21:      * Removes all elements from structure. After clear size is equal to 0
22:      */
23:     public function clear()
24:     {
25:         $this->data = array();
26:     }
27: 
28:     /** @return boolean */
29:     public function isEmpty()
30:     {
31:         return $this->size() == 0;
32:     }
33: 
34:     /** @return int */
35:     public function size()
36:     {
37:         return count($this->data);
38:     }
39: 
40:     protected function checkIfElementIsNotNull($element)
41:     {
42:         if (is_null($element)) {
43:             throw new NullArgumentException('Null inserted into the queue');
44:         }
45:     }
46: }
47: 
BN-PHP - Big Number data type for PHP API documentation generated by ApiGen 2.8.0