Core /

Maps

Index or Cache; that is the question.

Arrays can be indexed by a number (a list) or by a string (associative). Arrays may be multi-dimensional. PHP features a arrayAccess class with iterators. Nice. Boxary does encapsulate such arrays in a Map class. The reason is that the application code should refer to a array member in a consistent way: $A = $myMap->get('key'); Boxary features several classes extending the abstract baseMap: simpleMap, multiMap, objectMap, tensorMap and functorMap. These maps are used for config values, language constructs, database data, tree models, dependencies, and for everything that is indexed or needs caching.

Common Maps.

  • simpleMap and stampMap
  • referenceMap or multiMap
  • closureMap or objectMap or functorMap
  • tensorMap

Stacks and Queues.

A specialised form of Maps is the Stack and the Queue. They come with specialised methods like pop() and push() for Stacks and deQueue() and enQueue() for Queues. A good example of application is the sqlStack where sql syntax is stacked and serialised either to real sql, either to a prepared statement.

While Maps are accessed random, Stacks are LIFO structures and Queues are FIFO structures.