2017 © Pedro Peláez
 

library collections

Generic collections for the XP Framework

image

xp-framework/collections

Generic collections for the XP Framework

  • Sunday, May 28, 2017
  • by thekid
  • Repository
  • 2 Watchers
  • 0 Stars
  • 40,218 Installations
  • PHP
  • 10 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 8 % Grown

The README.md

Collections

Build status on GitHub XP Framework Module BSD Licence Requires PHP 7.0+ Supports PHP 8.0+ Latest Stable Version, (*1)

Generic collections for the XP Framework, (*2)

API

package util.collections {
  public interface util.collections.IList<T>
  public interface util.collections.Map<K, V>
  public interface util.collections.Set<T>

  public class util.collections.HashSet<T>
  public class util.collections.HashTable<K, V>
  public class util.collections.LRUBuffer<T>
  public class util.collections.Pair<K, V>
  public class util.collections.Queue<T>
  public class util.collections.Stack<T>
  public class util.collections.Vector<T>
}

Example: HashTable

$map= create('new util.collections.HashTable<string, com.example.Customer>');
$empty= $map->isEmpty();
$size= $map->size();

// Write values
$map['@example']= new Customer(0, 'Example customer');
$map->put('@friebe', new Customer(1, 'Timm Friebe'));

// Raises an exception
$map['@invalid']= new Date();

// Access
$customer= $map['@example'];
$customer= $map->get('@example');

// Test
if (isset($map['@example'])) {
  // ...
}

// Will return NULL
$customer= $map['@nonexistant'];

// Remove
unset($map['@example']);
$map->remove('@example');

// Iteration
foreach ($map as $pair) {
  echo $pair->key, ': ', $pair->value->toString(), "\n";
}

Example: Vector

$list= create('new util.collections.Vector<com.example.Customer>');
$empty= $list->isEmpty();
$size= $list->size();

// Write values
$list[]= new Customer(0, 'Example customer');
$list->add(new Customer(1, 'Timm Friebe'));

$list[0]= new Customer(0, 'Example customer');
$list->set(1, new Customer(1, 'Timm Friebe'));

// Raises an exception
$list[0]= new Date();

// Access
$customer= $list[0];
$customer= $list->get(0);

// Test
if (isset($list[1])) {
  // ...
}

// Will return NULL
$customer= $list[1];

// Remove
unset($list[1]);
$list->remove(1);

// Iteration
foreach ($list as $customer) {
  echo $customer->toString(), "\n";
}

Further reading

The Versions

28/05 2017

dev-master

9999999-dev http://xp-framework.net/

Generic collections for the XP Framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp

28/05 2017

v8.0.0

8.0.0.0 http://xp-framework.net/

Generic collections for the XP Framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp

23/04 2017

v7.3.0

7.3.0.0 http://xp-framework.net/

Generic collections for the XP Framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp

28/08 2016

v7.2.0

7.2.0.0 http://xp-framework.net/

Generic collections for the XP Framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp

24/07 2016

v7.1.0

7.1.0.0 http://xp-framework.net/

Generic collections for the XP Framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp

21/02 2016

v7.0.0

7.0.0.0 http://xp-framework.net/

Generic collections for the XP Framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp

08/11 2015

v6.5.6

6.5.6.0 http://xp-framework.net/

Generic collections for the XP Framework

  Sources   Download

BSD-3-Clause

The Requires

 

module xp