Coder Social home page Coder Social logo

php_linkedlist_extension's Introduction

linklist-php-extension

link list datastruct for php

2018-07-15 日更新,支持php7,使用最新的zend_value中的void *ptr类型,之前版本中基于resource的实现请切换到php5分支

说明: 转眼间,已经正式参加工作一年时间了,也意味着告别学生时代整整一年。在这一年里,从一开始的很不适应到适应,一个人也经历了许许多多的辛酸。回顾这一年,一半在无所事事,一半在碌碌无为。很早就计划着能做点什么,可是却总是很难付诸行动。 那么以此作为留念吧。

methods

add_head();
fetch_head();
add_tail();
fetch_tail();
fetch_index();
delete_index();
element_nums();

Demo

<?php
$list = new Lb\Linklist();

for ($i = 0; $i < 10; $i++) {
    $list->add_head("hello liubang" . $i);
}

for ($i = 0; $i < $list->element_nums(); $i++) {
    echo $list->fetch_index($i) , PHP_EOL;
}

$list->delete_index(3);
echo $list->element_nums();
echo PHP_EOL;


for ($i = 0; $i < $list->element_nums(); $i++) {
    echo $list->fetch_index($i) , PHP_EOL;
}

$list->add_tail(array(
    'userId' => 1034285,
    'userName' => '东北狠人'
));


var_dump($list->fetch_tail());


class Demo {
    public $name;
    public $gender;
    public function __construct($name, $gender) {
        $this->name = $name;
        $this->gender = $gender;
    }
}
$d = new Demo("刘邦", "");
$list->add_head($d);

var_dump($list->fetch_head());

php_linkedlist_extension's People

Contributors

liubang avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.