note 80734 added to ref.array

From: Date: Wed, 30 Jan 2008 10:09:46 +0000
Subject: note 80734 added to ref.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-135592@lists.php.net to get a copy of this message
I've created a class which is comparable to a Vector in C++; <?php class Vector { public $nb_elements; public $liste; public function Vector() { $this->liste = array (); $this->nb_elements = count($this->liste); } public function push_back($valeur) { if (!empty ($valeur)) { $this->liste[] = $valeur; $this->nb_elements = count($this->liste); return true; } else { return false; } } public function insert_at($indice, $valeur) { if ($indice > 0 && $indice < $this->nb_elements) { for ($i = $this->nb_elements; $i != $indice; $i--) { $this->liste[$i] = $this->liste[$i -1]; } $this->liste[$indice] = $valeur; $this->nb_elements = count($this->liste); return true; } else { return false; } } public function remove_at($indice) { if ($indice > 0 && $indice < $this->nb_elements) { for ($i = $indice; $i != $this->nb_elements - 1; $i++) { $this->liste[$i] = $this->liste[$i +1]; } array_pop($this->liste); $this->nb_elements = count($this->liste); return true; } else { return false; } } public function pop() { $value = array_pop($this->liste); $this->nb_elements = count($this->liste); return $value; } public function shift() { $value = array_shift($this->liste); $this->nb_elements = count($this->liste); return true; } } ?> ---- Server IP: 217.174.223.124 Probable Submitter: 195.7.113.182 ---- Manual Page -- http://www.php.net/manual/en/ref.array.php Edit -- https://master.php.net/note/edit/80734 Del: integrated -- https://master.php.net/note/delete/80734/integrated Del: useless -- https://master.php.net/note/delete/80734/useless Del: bad code -- https://master.php.net/note/delete/80734/bad+code Del: spam -- https://master.php.net/note/delete/80734/spam Del: non-english -- https://master.php.net/note/delete/80734/non-english Del: in docs -- https://master.php.net/note/delete/80734/in+docs Del: other reasons-- https://master.php.net/note/delete/80734 Reject -- https://master.php.net/note/reject/80734 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#135592) next »