php实现单链表(静态链表)
<?php /* * 单链表的PHP实现 * * @author zhaojiangwei * @since 2011/10/20 */ //结点类 class Node{ private $next = NULL; //下一个结点指针 private $data = NULL; //数据 public function Node($data, $next = NULL){ $this->data = $data; $next && $this->next = $next; } public function getData(){ return $this->data; } public function setData($data){ $this->data = $data; } public function getNext(){ return $this->next; } public function setNext($next){ $this->next = $next; } } //单链表类 class LinkList{ private $data_list = NULL; //结点集 public function LinkList($data = false){ $this->data_list = array(); $title = new Node(NULL); $this->data_list[] = $title; if($data){ if(is_array($data)){ $this->addMoreData($data); }else{ $this->addData($data); } } } //返回第N个结点的值 public function getNodeByNumber($number){ return $this->data_list[$this->findKeyByNumber($number)]->getData(); } //添加一组结点 public function addMoreData($datas){ foreach($datas as $value){ $this->addData($value); } } //添加结点统一入口,供外面调用 //$number 添加在第几个结点的后面 public function addData($data, $number = false){ $node = new Node($data); if($number === FALSE || $number == count($this->data_list)){ $this->insertLastNode($node); }elseif($number > count($this->data_list)){ return false; }else{ $this->insertNode($node, $number); } } //插入一个结点到最后 private function insertLastNode($node){ $node->setNext(NULL); $lastKey = $this->findLastNode(); $insert_key = $this->insertNodeIntoArray($node); $this->data_list[$lastKey]->setNext($insert_key); } //插入一个结点 private function insertNode($node, $number){ $insert_number = $this->findKeyByNumber($number); $node->setNext($this->data_list[$insert_number]->getNext()); $insert_key = $this->insertNodeIntoArray($node); $this->data_list[$insert_number]->setNext($insert_key); } //查找第N个结点对应的数组key private function findKeyByNumber($number){ $i = $key = 0; while($i < $number){ $key = $this->data_list[$key]->getNext(); $i ++; } return $key; } //将结点加入数组 private function insertNodeIntoArray($node){ $this->data_list[] = $node; return $this->getLastKey(); } //删除结点 public function deleteNode($number){ if($number == 0 || $number > count($this->data_list)){ return false; } $pre_key = $this->findKeyByNumber($number - 1); $key = $this->data_list[$pre_key]->getNext(); $this->data_list[$pre_key]->setNext($this->data_list[$key]->getNext()); unset($this->data_list[$key]); } //查找某结点的前一个结点 private function getPreNodeKey($key){ foreach($this->data_list as $k=>$v){ if($v->getNext() == $key){ return $k; } } return false; } //打印链表 public function getData_list(){ return $this->data_list; } //返回数组的最后一个键 private function getLastKey(){ end($this->data_list); return key($this->data_list); } //判断某个键值是否存在 private function ifExistKey($key){ if(array_key_exists($key, $this->data_list)){ return true; } return false; } //查找尾结点 public function findLastNode(){ foreach($this->data_list as $key=>$value){ if($value->getNext() === NULL){ return $key; } } } } ?>

许多用户在选择智能手表的时候都会选择的华为的品牌,其中华为GT3pro和GT4都是非常热门的选择,不少用户都很好奇华为GT3pro和GT4有什么区别,下面就就给大家介绍一下二者。华为GT3pro和GT4有什么区别一、外观GT4:46mm和41mm,材质是玻璃表镜+不锈钢机身+高分纤维后壳。GT3pro:46.6mm和42.9mm,材质是蓝宝石玻璃表镜+钛金属机身/陶瓷机身+陶瓷后壳二、健康GT4:采用最新的华为Truseen5.5+算法,结果会更加的精准。GT3pro:多了ECG心电图和血管及安

function是函数的意思,是一段具有特定功能的可重复使用的代码块,是程序的基本组成单元之一,可以接受输入参数,执行特定的操作,并返回结果,其目的是封装一段可重复使用的代码,提高代码的可重用性和可维护性。

为什么截图工具在Windows11上不起作用了解问题的根本原因有助于找到正确的解决方案。以下是截图工具可能无法正常工作的主要原因:对焦助手已打开:这可以防止截图工具打开。应用程序损坏:如果截图工具在启动时崩溃,则可能已损坏。过时的图形驱动程序:不兼容的驱动程序可能会干扰截图工具。来自其他应用程序的干扰:其他正在运行的应用程序可能与截图工具冲突。证书已过期:升级过程中的错误可能会导致此issu简单的解决方案这些适合大多数用户,不需要任何特殊的技术知识。1.更新窗口和Microsoft应用商店应用程

第1部分:初始故障排除步骤检查苹果的系统状态:在深入研究复杂的解决方案之前,让我们从基础知识开始。问题可能不在于您的设备;苹果的服务器可能会关闭。访问Apple的系统状态页面,查看AppStore是否正常工作。如果有问题,您所能做的就是等待Apple修复它。检查您的互联网连接:确保您拥有稳定的互联网连接,因为“无法连接到AppStore”问题有时可归因于连接不良。尝试在Wi-Fi和移动数据之间切换或重置网络设置(“常规”>“重置”>“重置网络设置”>设置)。更新您的iOS版本:

在本文中,我们将了解enumerate()函数以及Python中“enumerate()”函数的用途。什么是enumerate()函数?Python的enumerate()函数接受数据集合作为参数并返回一个枚举对象。枚举对象以键值对的形式返回。key是每个item对应的索引,value是items。语法enumerate(iterable,start)参数iterable-传入的数据集合可以作为枚举对象返回,称为iterablestart-顾名思义,枚举对象的起始索引由start定义。如果我们忽

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code<form name="myform"

MySQL.proc表的作用和功能详解MySQL是一种流行的关系型数据库管理系统,开发者在使用MySQL时常常会涉及到存储过程(StoredProcedure)的创建和管理。而MySQL.proc表则是一个非常重要的系统表,它存储了数据库中所有的存储过程的相关信息,包括存储过程的名称、定义、参数等。在本文中,我们将详细解释MySQL.proc表的作用和功能

data文件夹里面是系统及程序的数据,比如软件的设置和安装包等,Data文件夹中各个文件夹则代表的是不同类型的数据存放文件夹,无论Data文件指的是文件名Data还是扩展名data,都是系统或程序自定义的数据文件,Data是数据保存的备份类文件,一般可以用meidaplayer、记事本或word打开。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.