All Projects → maxalmonte14 → Phpcollections

maxalmonte14 / Phpcollections

A set of collections for PHP.

Projects that are alternatives of or similar to Phpcollections

Mlib
Library of generic and type safe containers in pure C language (C99 or C11) for a wide collection of container (comparable to the C++ STL).
Stars: ✭ 321 (+505.66%)
Mutual labels:  stack, dictionary, collections, generic
Buckets Js
A complete, fully tested and documented data structure library written in pure JavaScript.
Stars: ✭ 1,128 (+2028.3%)
Mutual labels:  stack, dictionary, collections, collection
Containers
This library provides various containers. Each container has utility functions to manipulate the data it holds. This is an abstraction as to not have to manually manage and reallocate memory.
Stars: ✭ 125 (+135.85%)
Mutual labels:  stack, collections, collection
Cdsa
A library of generic intrusive data structures and algorithms in ANSI C
Stars: ✭ 549 (+935.85%)
Mutual labels:  stack, collections, generic
Sc
Common libraries and data structures for C.
Stars: ✭ 161 (+203.77%)
Mutual labels:  stack, collections, generic
Data Structures With Go
Data Structures with Go Language
Stars: ✭ 121 (+128.3%)
Mutual labels:  stack, dictionary, collections
Golang Examples
Some examples for the programming language Go.
Stars: ✭ 14 (-73.58%)
Mutual labels:  stack, generic
indicium
🔎 A simple in-memory search for collections and key-value stores.
Stars: ✭ 41 (-22.64%)
Mutual labels:  collection, collections
go-streams
Stream Collections for Go. Inspired in Java 8 Streams and .NET Linq
Stars: ✭ 127 (+139.62%)
Mutual labels:  collection, collections
NonEmptyCollections
A type-safe implementation for collections that cannot be empty. Life is too short for emptiness-checks!
Stars: ✭ 45 (-15.09%)
Mutual labels:  collection, collections
php-underscore
PHP underscore inspired &/or cloned from _.js, with extra goodies like higher order messaging
Stars: ✭ 42 (-20.75%)
Mutual labels:  collection, collections
Libgenerics
libgenerics is a minimalistic and generic library for C basic data structures.
Stars: ✭ 42 (-20.75%)
Mutual labels:  stack, generic
Staticvec
Implements a fixed-capacity stack-allocated Vec alternative backed by an array, using const generics.
Stars: ✭ 236 (+345.28%)
Mutual labels:  stack, collections
HelloWorlds
Hello-World program in most programming languages
Stars: ✭ 102 (+92.45%)
Mutual labels:  collection, collections
Redux Data Structures
Reducer factory functions for common data structures: counters, maps, lists (queues, stacks), sets, etc.
Stars: ✭ 157 (+196.23%)
Mutual labels:  stack, dictionary
SwiftConcurrentCollections
Swift Concurrent Collections
Stars: ✭ 40 (-24.53%)
Mutual labels:  collection, collections
Javascript Datastructures Algorithms
📚 collection of JavaScript and TypeScript data structures and algorithms for education purposes. Source code bundle of JavaScript algorithms and data structures book
Stars: ✭ 3,221 (+5977.36%)
Mutual labels:  stack, dictionary
Soapengine
This generic SOAP client allows you to access web services using a your iOS app, Mac OS X app and AppleTV app.
Stars: ✭ 468 (+783.02%)
Mutual labels:  dictionary, generic
Collections.pooled
Fast, low-allocation ports of List, Dictionary, HashSet, Stack, and Queue using ArrayPool and Span.
Stars: ✭ 115 (+116.98%)
Mutual labels:  stack, dictionary
MyGoldenDict
My personal goldendict-dictionaries collection
Stars: ✭ 13 (-75.47%)
Mutual labels:  collection, dictionary

StyleCI Scrutinizer Code Quality Build Status

About PHPCollections

PHPCollections is a set of data structures that try to make your life easier when you're working with PHP and large sets of data. Inspired by languages like Java or C#, PHPCollections offers data structures like List, Map, Stack and more, check it out!

Requirements

PHP >= 7.2

Installation

composer require "maxalmonte14/phpcollections"

Examples

Imagine you're storing Post objects for fetching like so.

$posts[] = new Post(1, 'PHP 7.2 release notes');
$posts[] = new Post(2, 'New Laravel 5.5 LTS make:factory command');

Everything is fine! But maybe you made a mistake for some mysterious reason and added a non-Post object.

$posts[] = 5 // This is not even an object!

When you'll try to fetch your posts array you'll be in troubles.

<?php foreach($posts as $post): ?>
    <tr>
        <!-- this gonna fail when $post == 5! -->
        <td><?= $post->id; ?></td>
        <td><?= $post->title; ?></td>
    </tr>
<?php endforeach ?>

Fortunately PHPCollections exists.

$posts = new GenericList(
    Post::class,
    new Post(1, 'PHP 7.2 release notes'),
    new Post(2, 'New Laravel 5.5 LTS make:factory command')
);
$posts->add(5); // An InvalidArgumentException is thrown!

Of course there exist more flexible data structures like ArrayList.

$posts = new ArrayList();
$posts->add(new Post(1, 'PHP 7.2 release notes'));
$posts->add(new Post(2, 'New Laravel 5.5 LTS make:factory command'));
$posts->add(5); // Everything is fine, I need this 5 anyway

Features

  • Different types of collections like Dictionary, Stack and GenericList.
  • Simple API.
  • Lightweight, no extra packages needed.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].