adrianoferreira/data-structures

A set of data structures implemented in PHP.

dev-master 2020-01-24 18:20 UTC

This package is auto-updated.

Last update: 2024-04-25 04:45:21 UTC


README

Build Status Build Status Total Downloads License

A set of data structures implemented in PHP:

  • Hash Table
  • More soon...

Installation

It's recommended that you use Composer to install this library.

$ composer require adrianoferreira/data-structures:dev-master

Usage

$hashTable = new \AdrianoFerreira\DS\HashTable\Table( 10 );
$hashTable->insert( 'my-key', 'my value' );
$hashTable->insert( 'my-key', 'updated value' );
$hashTable->insert( 'other-key', 'other value' );
$hashTable->insert( 'abc', 'abc value' );
$hashTable->insert( 'cba', 'cba value' );

//Outputs 'updated value' as it replaces the value of buckets with same key
echo $hashTable->get('my-key');

//Outputs 'other value'
echo $hashTable->get('other-key');

//Outputs 'cba value'
echo $hashTable->get('cba');