PHPackages                             appserver-io/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. appserver-io/collections

ActiveLibrary

appserver-io/collections
========================

Package that provides basic PHP collections and utilities.

2.0.0(8y ago)411.6k4[1 issues](https://github.com/appserver-io/collections/issues)7OSL-3.0PHPPHP &gt;=5.4.0 &lt; 8.0

Since Nov 21Pushed 8y ago3 watchersCompare

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

READMEChangelogDependencies (2)Versions (9)Used By (7)

PHP collection library
======================

[](#php-collection-library)

[![Latest Stable Version](https://camo.githubusercontent.com/5247411e05ee53cee60c41aea66a853fd57b6226749c5ac617e1ced459191726/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6170707365727665722d696f2f636f6c6c656374696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/appserver-io/collections)[![Total Downloads](https://camo.githubusercontent.com/cca956e7e0b6cfd3ae3b4e3df3096e908e23d6a168b74f26af7a5bece234accd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6170707365727665722d696f2f636f6c6c656374696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/appserver-io/collections)[![License](https://camo.githubusercontent.com/6aee0f65f0e484ab4d5a5d9f878a3a3f75d1b559fdb54230fa0a01f4505053ce/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6170707365727665722d696f2f636f6c6c656374696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/appserver-io/collections)[![Build Status](https://camo.githubusercontent.com/dd6716bac35df01bd888d327130ffc9de01116b93c55feff21f8170564887b8c/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6170707365727665722d696f2f636f6c6c656374696f6e732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](http://travis-ci.org/appserver-io/collections)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/824772b1c6e0dd1eb8ed2c307c25a69aa4f65b559c89795bf97a8bb4e69f0ff5/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6170707365727665722d696f2f636f6c6c656374696f6e732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/appserver-io/collections/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/2927ba08841a18464858420e80e822695f03a6910bc3032753da5bf544ff77d3/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6170707365727665722d696f2f636f6c6c656374696f6e732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/appserver-io/collections/?branch=master)

Introduction
------------

[](#introduction)

This package provides a generic collection library.

The library is based on the SPL extension of PHP5 and uses the introduced iterators. The library also provides, beside the most used collection types, interfaces and exceptions.

Issues
------

[](#issues)

In order to bundle our efforts we would like to collect all issues regarding this package in [the main project repository's issue tracker](https://github.com/appserver-io/appserver/issues). Please reference the originating repository as the first element of the issue title e.g.: `[appserver-io/] A issue I am having`

Usage
-----

[](#usage)

The following examples will give you a short introduction how you can use the classes provided by this library.

### ArrayList

[](#arraylist)

An ArrayList will provide a container that can store items of different data types. With the provided methods, elements can be added, returned oder deleted. The ArrayList is unsorted and has an ongoing integer index that starts with 0.

```
// initialize a new ArrayList object $list = new ArrayList();
// add several values
$list->add(new Integer(1));
$list->add(new Integer(2));
foreach($list as $key => $item) {
    echo "Found item with key " . $key . " value " . $item->__toString() . PHP_EOL;
}

// produces the following output
Found item with key 0 and value 1 Found item with key 1 and value 2
```

### HashMap

[](#hashmap)

A HashMap will provide a container that can store items of different data types. With the provided methods, elements can be added, returned oder deleted. The HashMap is unsorted like an ArrayList and all simple data types are supported as index.

```
// initialize a new HashMap object
$map = new HashMap();

// add several values
$map->add("number", new Integer(1));
$map->add("string", new String("foo"));
foreach($list as $key => $item) {
    echo "Found item with key " . $key . " and value " . $item->__toString() . PHP_EOL;
}

// produces the following output
Found item with key number and value 1 Found item with key string and value foo
```

### Dictionary

[](#dictionary)

A Dictionary, like an ArrayList or a HashMap, will provide a container that can store items of different data types. With the provided methods, elements can be added, returned oder deleted. The Dictionary is unsorted like an ArrayList. But in opposite to an ArrayList or a HashMap, between simple data types, also objects are allowed as index.

```
// initialize a new Dictionary object
$dictionary = new Dictionary();

// add several values
$dictionary->add(new Integer(1), new Integer(12));
$dictionary->add(new String("foo"), new String("foo"));

foreach($dictionary as $key => $item) {
    echo "Found item with key " . $key->__toString() . " and value " . $item->__toString() . PHP_EOL;
}

// produces the following output
Found item with key 1 and value foo Found item with key foo and value 12
```

### TreeMap

[](#treemap)

The usage of a TreeMap is very similar to a HashMap. The main difference is, that the items are either sorted ascending, or by the Predicate passed to the constructor.

```
// initialize a new TreeMap object
$map = new TreeMap();

// add several values
$map->add(2, new Integer(12));
$map->add(1, new String("foo"));

foreach($map as $key => $item) {
    echo "Found item with key " . $key . " and value " . $item->__toString() . PHP_EOL;
}

// produces the following output
Found item with key 1 and value foo Found item with key 2 and value 12
```

The next example gives you an example implementation for using a TreeMap, sorted with a Comparator.

```
/**
 * A class TestComparator to sort TreeMap by value.
 */
class TestComparator implements Comparator
{

    public function compare($object1, $object2)
    {

        if ($object1->intValue() < $object2->intValue()) {
            return -1;
        }

        if ($object1->intValue() > $object2->intValue()) {
            return 1;
        }

        if ($object1->intValue() == $object2->intValue()) {
            return 0;
        }
    }
}

// initialize a new TreeMap object and pass the TestComparator to the constructor
$map = new TreeMap(new TestComparator());

// add several values
$map->add(1, new Integer(14));
$map->add(2, new Integer(13));
$map->add(3, new Integer(15));

foreach($map as $key => $item) {
    echo "Found item with key " . $key . " and value " . $item->__toString() . PHP_EOL;
}

// produces the following output
Found item with key 2 and value 13 Found item with key 1 and value 14 Found item with key 3 and value 15
```

External Links
--------------

[](#external-links)

- Documentation at [appserver.io](http://docs.appserver.io)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community25

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~132 days

Recently: every ~176 days

Total

8

Last Release

3259d ago

Major Versions

0.2.0 → 1.0.02015-02-13

1.1.0 → 2.0.02017-06-07

PHP version history (2 changes)0.1.1PHP &gt;=5.4.0

2.0.0PHP &gt;=5.4.0 &lt; 8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/76b54aaecf7287a0520eec0009161ca457982dee83ac413bfa0d818b72d79947?d=identicon)[wagnert](/maintainers/wagnert)

![](https://www.gravatar.com/avatar/33b42e8c7314da5df45bca5d1dd786ea2b3d540fae5a5a9489580a886f2f4f39?d=identicon)[zelgerj](/maintainers/zelgerj)

![](https://www.gravatar.com/avatar/aa15f27f393eeb1f1a481fa7de89b41add17de686da79d49e07c5c77249c5e86?d=identicon)[wick-ed](/maintainers/wick-ed)

---

Top Contributors

[![wagnert](https://avatars.githubusercontent.com/u/287509?v=4)](https://github.com/wagnert "wagnert (11 commits)")[![wick-ed](https://avatars.githubusercontent.com/u/4931168?v=4)](https://github.com/wick-ed "wick-ed (9 commits)")[![vadimjustus](https://avatars.githubusercontent.com/u/4609608?v=4)](https://github.com/vadimjustus "vadimjustus (4 commits)")[![zelgerj](https://avatars.githubusercontent.com/u/287595?v=4)](https://github.com/zelgerj "zelgerj (1 commits)")

---

Tags

collection arraylist map tree sorted set dictionary comparator predicate

### Embed Badge

![Health badge](/badges/appserver-io-collections/health.svg)

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

PHPackages © 2026

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