morrisonlevi

Possible PHP data-structure outline

Dec 17th, 2011
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. <?php
  2. /**
  3.  * The purpose of this document is to brainstorm a possible inheritance scheme
  4.  * usable for a new set of PHP data-structures.  It is by no means final.
  5.  */
  6. namespace Spl;
  7.  
  8. /**
  9.  * By Collection, we do not mean the same thing as a Java collection. It is
  10.  * simply a name by which we can give generic properties to.
  11.  *
  12.  *
  13.  */
  14. interface Collection extends \Countable, \Iterator, \Serializable {
  15.     function clear();
  16.     function contains($item);
  17.     function isEmpty();
  18. }
  19.  
  20. interface Vector extends Collection, \ArrayAccess {
  21.        
  22. }
  23.  
  24. class ArrayList implements Vector {
  25.    
  26. }
  27.  
  28. class LinkedList implements Vector {
  29.  
  30. }
  31.  
  32. class Stack implements \Collection  {
  33.    
  34.     function peek();
  35.     function pop();
  36.     function push($item);
  37.    
  38. }
  39.  
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment