PHP Classes

PHP Linked List: Manage elements stored in a linked list

Recommend this page to a friend!
  Info   View files Example   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 109 This week: 1All time: 9,634 This week: 560Up
Version License PHP version Categories
linked-list 1.0.0MIT/X Consortium ...5PHP 5, Data types
Description 

Author

This class can manage elements stored in a linked list.

It can values to a linked list by creating nodes that point to the next and previous elements of the list.

The class can also get elements by specific position, get the first and last elements.

It can also display the list of elements in the linked list.

Picture of Biswarup Adhikari
  Performance   Level  
Name: Biswarup Adhikari <contact>
Classes: 1 package by
Country: India India
Age: 36
All time rank: 4384299 in India India
Week rank: 416 Up25 in India India Up

Example

<?php
/**
 * examples.php
 * @category DataStructure
 * @package PHPLinkedList Example
 * @author Biswarup Adhikari <biswarupadhikari@gmail.com>
 */
require_once 'PHPLinkedList.php';
/**
 * Create New LinkedList
 */
$myLinkedList=new PHPLinkedList;
//Add New Item To List
$myLinkedList->put(1);
$myLinkedList->put("Biswarup");

//Append Item
$myLinkedList->append("biswarupadhikari@gmail.com");

//Prepend Item
$myLinkedList->prepend("www.biswarupadhikari.com");

//Get First Item
var_dump($myLinkedList->first());

//Get Last Item
var_dump($myLinkedList->last());
//Get Item By Position
var_dump($myLinkedList->get(0));
var_dump($myLinkedList->get(2));

//Total Number Of Items
var_dump($myLinkedList->count());


// $i=0;
// while(true)
// {
// //$myLinkedList->printChain();
// $myLinkedList->append($i);
// var_dump($myLinkedList->count());
// $i++;
// //sleep(1);
// }


Details

Include PHPLinkedList Class

<?php 
require_once 'PHPLinkedList.php';

Initialize new LinkedList

$myLinkedList=new PHPLinkedList;

Add New Item To LinkedList

$myLinkedList->put(1);
$myLinkedList->put("Biswarup");

Append Item

$myLinkedList->append("biswarupadhikari@gmail.com");

Prepend Item

$myLinkedList->prepend("www.biswarupadhikari.com");

Get First Item From LinkedList

var_dump($myLinkedList->first());

Get Last Item From Linked List

var_dump($myLinkedList->last());

Get Item From LinkedList By Position

var_dump($myLinkedList->get(0));
var_dump($myLinkedList->get(2));
``

# Count Total Number Of Items

var_dump($myLinkedList->count());


# How to run test cases

$ php test.php


  Files folder image Files  
File Role Description
Accessible without login Plain text file examples.php Example PHPLinkedList Examples
Plain text file PHPLinkedList.php Class PHPLinkedList Main Class
Accessible without login Plain text file README Doc. PHPLinkedList Documentation
Accessible without login Plain text file test.php Test PHPLinkedList Test Cases

 Version Control Unique User Downloads Download Rankings  
 0%
Total:109
This week:1
All time:9,634
This week:560Up