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

AbandonedArchivedLibrary

techdivision/collections
========================

Package that provides basic PHP collections and utilities.

0.1.1(11y ago)42.8k11OSL-3.0PHPPHP &gt;=5.4.0

Since Jul 11Pushed 11y ago9 watchersCompare

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

READMEChangelog (1)Dependencies (3)Versions (3)Used By (1)

TechDivision\_Collections
=========================

[](#techdivision_collections)

[![Latest Stable Version](https://camo.githubusercontent.com/7306c681a02a552879c1ec918f9576c1fa8bfe6658a37e669f3dbed2a1614d52/68747470733a2f2f706f7365722e707567782e6f72672f746563686469766973696f6e2f636f6c6c656374696f6e732f762f737461626c652e706e67)](https://packagist.org/packages/techdivision/collections) [![Total Downloads](https://camo.githubusercontent.com/f3eaa034b65a245f3b26a464548cf231b231e8b7b6749f84bdc9409d8665a24b/68747470733a2f2f706f7365722e707567782e6f72672f746563686469766973696f6e2f636f6c6c656374696f6e732f646f776e6c6f6164732e706e67)](https://packagist.org/packages/techdivision/collections) [![Latest Unstable Version](https://camo.githubusercontent.com/22d4e59d425296ebd5cea5687f3897b6686659eb52f4ff3512ed7bbcecca973e/68747470733a2f2f706f7365722e707567782e6f72672f746563686469766973696f6e2f636f6c6c656374696f6e732f762f756e737461626c652e706e67)](https://packagist.org/packages/techdivision/collections) [![License](https://camo.githubusercontent.com/4b38bb2b2c8a19460c07302dc932e30cb64dedf0aac4e08ef1bc95da839b91ce/68747470733a2f2f706f7365722e707567782e6f72672f746563686469766973696f6e2f636f6c6c656374696f6e732f6c6963656e73652e706e67)](https://packagist.org/packages/techdivision/collections) [![Build Status](https://camo.githubusercontent.com/0c8ecca912d9cdb7cbfc907f666ae294f8bfed957f2c032e5a11297ea4dd6053/68747470733a2f2f7472617669732d63692e6f72672f746563686469766973696f6e2f546563684469766973696f6e5f436f6c6c656374696f6e732e706e67)](https://travis-ci.org/techdivision/TechDivision_Collections)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/09b02879ff7d853a9dd7ef72137b3cb07f9c99be9e3a5f14b49f9935f0618d1e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f746563686469766973696f6e2f546563684469766973696f6e5f436f6c6c656374696f6e732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/techdivision/TechDivision_Collections/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/241d60f79ac5e9f16fb56cd321f1a33200dffed4a53d3f484c470aaffdec4696/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f746563686469766973696f6e2f546563684469766973696f6e5f436f6c6c656374696f6e732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/techdivision/TechDivision_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.

Installation
------------

[](#installation)

If you want to use the library with your application you can install it by adding

```
{
    "require": {
        "techdivision/collections": "dev-master"
    },
}
```

to your `composer.json` and invoke `composer update` in your project.

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($map 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)
- Documentation on [GitHub](https://github.com/techdivision/TechDivision_AppserverDocumentation)
- [Getting started](https://github.com/techdivision/TechDivision_AppserverDocumentation/tree/master/docs/getting-started)

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 61.9% 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 ~14 days

Total

2

Last Release

4315d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/287509?v=4)[Tim Wagner](/maintainers/wagnert)[@wagnert](https://github.com/wagnert)

![](https://avatars.githubusercontent.com/u/4931168?v=4)[Bernhard Wick](/maintainers/wick-ed)[@wick-ed](https://github.com/wick-ed)

---

Top Contributors

[![wagnert](https://avatars.githubusercontent.com/u/287509?v=4)](https://github.com/wagnert "wagnert (13 commits)")[![wick-ed](https://avatars.githubusercontent.com/u/4931168?v=4)](https://github.com/wick-ed "wick-ed (7 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

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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