2017 © Pedro Peláez
 

library collections

Various implementations of Doctrine's Collection interface

image

malarzm/collections

Various implementations of Doctrine's Collection interface

  • Wednesday, December 20, 2017
  • by malarzm
  • Repository
  • 2 Watchers
  • 12 Stars
  • 7,137 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 4 Versions
  • 10 % Grown

The README.md

Collections

Build Status, (*1)

Various implementations of Doctrine's Collection interface allowing you to kickstart development of own ones. Each time an interface or an abstract class requires you to implement compare method it needs a standard PHP comparison function that returns an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second., (*2)

This library sports:, (*3)

SortedCollection

Collection that ensures it is always sorted, uses uasort by default however this can be changed via constructor argument. Example usage:, (*4)

class SortedCollection extends Malarzm\Collections\SortedCollection
{
    public function compare($a, $b)
    {
        // ...
    }
}

$coll = new SortedIntCollection([], 'usort');

ObjectSet

Collection that ensures it contains only one instance of a given object at a time thus providing very efficient contains implementation. Add/set calls are NOP in case of object being already in the collection., (*5)

It's ready to use right away., (*6)

Set

More general version of ObjectSet that bases on custom comparison function instead of object hashes effectively allowing you to store any kind of values in it. Add/set calls are NOP in case of value being already in the collection., (*7)

class Set extends Malarzm\Collections\Set
{
    public function compare($a, $b)
    {
        // ...
    }
}

Diffable

Collection that allows you to track changes done between snapshots (first one is taken just after constructing collection, next are taken at the discretion of developer by calling ->snapshot()). Use ->getAddedElements() and ->getRemovedElements() to get new and no longer existing elements respectively., (*8)

class Diffable extends Malarzm\Collections\Diffable
{
    public function compare($a, $b)
    {
        // ...
    }
}

Library also ships Malarzm\Collections\DiffableCollection interface than can be backed up by Malarzm\Collections\Mixin\Diffable trait for your own use., (*9)

ListArray

Collection that ensures held elements are always stored as a list (array indexed by consecutive numbers). An exception is thrown when trying to write to invalid index., (*10)

It's ready to use right away., (*11)

SortedList

Extended implementation of ListArray that additionally keeps elements sorted thus providing more efficient contains, indexOf and removeElement implementations., (*12)

class SortedList extends Malarzm\Collections\SortedList
{
    public function compare($a, $b)
    {
        // ...
    }
}

The Versions

20/12 2017

dev-read-only-collections

dev-read-only-collections http://www.doctrine-project.org

Various implementations of Doctrine's Collection interface

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maciej Malarz

array collections iterator

10/12 2016

dev-master

9999999-dev http://www.doctrine-project.org

Various implementations of Doctrine's Collection interface

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maciej Malarz

array collections iterator

10/12 2016

1.0.0

1.0.0.0 http://www.doctrine-project.org

Various implementations of Doctrine's Collection interface

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maciej Malarz

array collections iterator

04/03 2016

0.1.0

0.1.0.0 http://www.doctrine-project.org

Various implementations of Doctrine's Collection interface

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maciej Malarz

array collections iterator