PHPackages                             xp-framework/collections - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. xp-framework/collections

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

xp-framework/collections
========================

Generic collections for the XP Framework

v10.1.0(2y ago)0125.7k↓15.6%6BSD-3-ClausePHPPHP &gt;=7.0.0

Since Nov 8Pushed 2y ago1 watchersCompare

[ Source](https://github.com/xp-framework/collections)[ Packagist](https://packagist.org/packages/xp-framework/collections)[ Docs](http://xp-framework.net/)[ RSS](/packages/xp-framework-collections/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (14)Used By (6)

Collections
===========

[](#collections)

[![Build status on GitHub](https://github.com/xp-framework/collections/workflows/Tests/badge.svg)](https://github.com/xp-framework/collections/actions)[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)[![Requires PHP 7.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_0plus.svg)](http://php.net/)[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)[![Latest Stable Version](https://camo.githubusercontent.com/5c663dd0b34425f2d1505bc291adf9cbbdd29a5a3e96186f274760752b6cbb10/68747470733a2f2f706f7365722e707567782e6f72672f78702d6672616d65776f726b2f636f6c6c656374696f6e732f76657273696f6e2e706e67)](https://packagist.org/packages/xp-framework/collections)

Generic collections for the XP Framework

API
---

[](#api)

```
package util.collections {
  public interface util.collections.IList
  public interface util.collections.Map
  public interface util.collections.Set

  public class util.collections.HashSet
  public class util.collections.HashTable
  public class util.collections.LRUBuffer
  public class util.collections.Pair
  public class util.collections.Queue
  public class util.collections.Stack
  public class util.collections.Vector
}
```

Example: HashTable
------------------

[](#example-hashtable)

```
$map= create('new util.collections.HashTable');
$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
---------------

[](#example-vector)

```
$list= create('new util.collections.Vector');
$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
---------------

[](#further-reading)

- [RFC #0193: Generics optimization](https://github.com/xp-framework/rfc/issues/193)
- [RFC #0106: Array access / iteration / type boxing / generics](https://github.com/xp-framework/rfc/issues/106)
- [HHVM: Hack Language Reference: Generic](http://docs.hhvm.com/manual/en/hack.generics.php)
- [PHP RFC: Introduce generics into PHP](https://wiki.php.net/rfc/generics)

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~254 days

Recently: every ~360 days

Total

13

Last Release

786d ago

Major Versions

v6.5.6 → v7.0.02016-02-21

v7.3.0 → v8.0.02017-05-28

v8.0.2 → v9.0.02020-04-10

v9.0.0 → v10.0.02020-10-04

PHP version history (3 changes)v6.5.6PHP &gt;=5.5.0

v7.2.0PHP &gt;=5.6.0

v9.0.0PHP &gt;=7.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/07d18d882c8b4aaf3466432f64018214f2771eda333202175431ee7233795376?d=identicon)[thekid](/maintainers/thekid)

---

Top Contributors

[![thekid](https://avatars.githubusercontent.com/u/696742?v=4)](https://github.com/thekid "thekid (58 commits)")

---

Tags

generic-collectionsphpxp-frameworkmodulexp

### Embed Badge

![Health badge](/badges/xp-framework-collections/health.svg)

```
[![Health](https://phpackages.com/badges/xp-framework-collections/health.svg)](https://phpackages.com/packages/xp-framework-collections)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
