{"id":21056018,"url":"https://github.com/xp-framework/collections","last_synced_at":"2026-02-05T20:34:17.610Z","repository":{"id":57084827,"uuid":"45779186","full_name":"xp-framework/collections","owner":"xp-framework","description":"Generic Collections for the XP Framework","archived":false,"fork":false,"pushed_at":"2024-03-23T23:46:53.000Z","size":103,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-26T15:36:20.171Z","etag":null,"topics":["generic-collections","php","xp-framework"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xp-framework.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-11-08T12:18:48.000Z","updated_at":"2021-10-21T16:47:44.000Z","dependencies_parsed_at":"2024-11-20T00:02:52.956Z","dependency_job_id":null,"html_url":"https://github.com/xp-framework/collections","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/xp-framework/collections","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-framework%2Fcollections","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-framework%2Fcollections/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-framework%2Fcollections/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-framework%2Fcollections/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xp-framework","download_url":"https://codeload.github.com/xp-framework/collections/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-framework%2Fcollections/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29133400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T19:36:52.185Z","status":"ssl_error","status_checked_at":"2026-02-05T19:35:40.941Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["generic-collections","php","xp-framework"],"created_at":"2024-11-19T16:48:20.131Z","updated_at":"2026-02-05T20:34:17.590Z","avatar_url":"https://github.com/xp-framework.png","language":"PHP","readme":"Collections\n===========\n\n[![Build status on GitHub](https://github.com/xp-framework/collections/workflows/Tests/badge.svg)](https://github.com/xp-framework/collections/actions)\n[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)\n[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)\n[![Requires PHP 7.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_0plus.svg)](http://php.net/)\n[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)\n[![Latest Stable Version](https://poser.pugx.org/xp-framework/collections/version.png)](https://packagist.org/packages/xp-framework/collections)\n\nGeneric collections for the XP Framework\n\nAPI\n---\n```php\npackage util.collections {\n  public interface util.collections.IList\u003cT\u003e\n  public interface util.collections.Map\u003cK, V\u003e\n  public interface util.collections.Set\u003cT\u003e\n\n  public class util.collections.HashSet\u003cT\u003e\n  public class util.collections.HashTable\u003cK, V\u003e\n  public class util.collections.LRUBuffer\u003cT\u003e\n  public class util.collections.Pair\u003cK, V\u003e\n  public class util.collections.Queue\u003cT\u003e\n  public class util.collections.Stack\u003cT\u003e\n  public class util.collections.Vector\u003cT\u003e\n}\n```\n\nExample: HashTable\n------------------\n```php\n$map= create('new util.collections.HashTable\u003cstring, com.example.Customer\u003e');\n$empty= $map-\u003eisEmpty();\n$size= $map-\u003esize();\n\n// Write values\n$map['@example']= new Customer(0, 'Example customer');\n$map-\u003eput('@friebe', new Customer(1, 'Timm Friebe'));\n\n// Raises an exception\n$map['@invalid']= new Date();\n\n// Access\n$customer= $map['@example'];\n$customer= $map-\u003eget('@example');\n\n// Test\nif (isset($map['@example'])) {\n  // ...\n}\n\n// Will return NULL\n$customer= $map['@nonexistant'];\n\n// Remove\nunset($map['@example']);\n$map-\u003eremove('@example');\n\n// Iteration\nforeach ($map as $pair) {\n  echo $pair-\u003ekey, ': ', $pair-\u003evalue-\u003etoString(), \"\\n\";\n}\n```\n\nExample: Vector\n---------------\n```php\n$list= create('new util.collections.Vector\u003ccom.example.Customer\u003e');\n$empty= $list-\u003eisEmpty();\n$size= $list-\u003esize();\n\n// Write values\n$list[]= new Customer(0, 'Example customer');\n$list-\u003eadd(new Customer(1, 'Timm Friebe'));\n\n$list[0]= new Customer(0, 'Example customer');\n$list-\u003eset(1, new Customer(1, 'Timm Friebe'));\n\n// Raises an exception\n$list[0]= new Date();\n\n// Access\n$customer= $list[0];\n$customer= $list-\u003eget(0);\n\n// Test\nif (isset($list[1])) {\n  // ...\n}\n\n// Will return NULL\n$customer= $list[1];\n\n// Remove\nunset($list[1]);\n$list-\u003eremove(1);\n\n// Iteration\nforeach ($list as $customer) {\n  echo $customer-\u003etoString(), \"\\n\";\n}\n```\n\nFurther reading\n---------------\n* [RFC #0193: Generics optimization](https://github.com/xp-framework/rfc/issues/193)\n* [RFC #0106: Array access / iteration / type boxing / generics](https://github.com/xp-framework/rfc/issues/106)\n* [HHVM: Hack Language Reference: Generic](http://docs.hhvm.com/manual/en/hack.generics.php)\n* [PHP RFC: Introduce generics into PHP](https://wiki.php.net/rfc/generics)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-framework%2Fcollections","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxp-framework%2Fcollections","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-framework%2Fcollections/lists"}