PHP配列で単純なキューを実現

1086 ワード

	    ,   (talk is  easy , show me the code):

	dsize = $value;
		}
	
	
		//        
		public function enqueue($value =0){
	
			if(count($this->dqueue)> $this->dsize){
				return false;
			}
			array_push($this->dqueue, $value);
		}
	
		//         
		public function unqueue(){
			if(count($this->dqueue) <1){
				return false;
			}
			array_shift($this->dqueue);
		}
	
		//        
		public function isEmpty(){
			return current($this->dqueue) === false;
		}
	
		//       
		public function dsize(){
			return count($this->dqueue);
		}
	
	}
	
	
	
	$newQueue = new SimpleQueue(15);
	$newQueue->enqueue("111111");
	$newQueue->enqueue("222222");
	$newQueue->enqueue("3333333");
	var_dump($newQueue->dsize());
	var_dump($newQueue->isEmpty());
	$newQueue->unqueue();
	
	var_dump($newQueue->dsize());
	var_dump($newQueue->isEmpty());