位置: 编程技术 - 正文

[置顶] unity加载与链表([置顶]bilinovel)

编辑:rootadmin

推荐整理分享[置顶] unity加载与链表([置顶]bilinovel),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:[置顶]游戏名:chivalry2,[置顶]电影名字《收件人不详》,[置顶]电影名字《收件人不详》,[置顶]游戏名:chivalry2,[置顶]电影名字《收件人不详》,[置顶]从lv2开始开挂的原勇者候悠闲的异世界生活,[置顶]游戏名:chivalry2,[置顶]bilinovel,内容如对您有帮助,希望把文章链接给更多的朋友!

今天来给大家分享一下unity加载与链表,由于上一讲已经把加载说过了,所以这次我们就来说一下关于链表的问题,主要还是分享一下源代码,如果大家哪里有不懂的地方,可以在社区里面提问,我会及时的做出解答。

Unity 用C#写的链表类用于保存坐标点

1. using UnityEngine;

2. using System;

3. using System.Collections;

4.

5. /// <summary>

6. /// 结点类

7. namespace CS

8. {

9. /// </summary>

. public class ListNode

. {

. public Vector3 data; //ElemType

. public ListNode(){} // 构造函数

. public ListNode next;

. }

.

. /// <summary>

. /// 链表类

. /// </summary>

. public class LinkList{

.

. private ListNode first; //第一个结点

. public LinkList(){

. first = null;

. }

.

. public bool IsEmpty()

. {

. return first == null;

. }

.

.

. /// <summary>

. /// 在第k个元素之后插入x

. /// </summary>

. /// <param name="k"></param>

. /// <param name="x"></param>

. /// <returns></returns>

. public LinkList Insert( int k, Vector3 x )

. {

. if( k<0 )

. return null;

. ListNode pNode = first; //pNode将最终指向第k个结点

. for( int index = 1; index<k && pNode != null; index&#;&#; )

. pNode = pNode.next;

. if( k>0 && pNode == null )

. return null;//不存在第k个元素

. ListNode xNode = new ListNode();

. xNode.data = x;

. if( k>0 )

. {

. //在pNode之后插入

. xNode.next = pNode.next;

. pNode.next = xNode;

. }

. else

. {

. //作为第一个元素插入

. xNode.next = first;

. first = xNode;

. }

. return this;

. }

.

. public int Length()

. {

. ListNode current = first;

. int length = 0;

. while(current != null)

. {

. length&#;&#;;

. current = current.next;

. }

. return length;

. }

.

. /// <summary>

[置顶]
        unity加载与链表([置顶]bilinovel)

. /// 返回第k个元素至x中

. /// </summary>

. /// <param name="k"></param>

. /// <param name="x"></param>

. /// <returns>如果不存在第k个元素则返回false,否则返回true</returns>

. public bool Find( int k, ref Vector3 x )

. {

. if( k<1 )

. return false;

. ListNode current = first;

. int index = 1;

. while( index<k && current != null )

. {

. current = current.next;

. index&#;&#;;

. }

. if( current != null )

. {

. x = current.data;

. return true;

. }

. return false;

. }

.

. /// <summary>

. /// 返回x所在的位置

. /// </summary>

. /// <param name="x"></param>

. /// <returns>如果x不在表中则返回0</returns>

. public int Search( Vector3 x )

. {

. ListNode current = first;

. int index = 1;

. while( current != null && current.data !=x )

. {

. current = current.next;

. index&#;&#;;

. }

. if(current != null)

. return index;

. return 0;

. }

.

. /// <summary>

. /// 删除第k个元素,并用x返回其&#;

. /// </summary>

. /// <param name="k"></param>

. /// <param name="x"></param>

. /// <returns></returns>

. public LinkList Delete( int k, ref Vector3 x )

. {

. //如果不存在第k个元素则引发异常

. if( k<1 || first == null )

. return null;

. ListNode pNode = first; //pNode将最终指向第k个结点

. //将pNode移动至第k个元素,并从链表中删除该元素

. if( k == 1 ) //pNode已经指向第k个元素

. first = first.next; //删除之

. else

. {

. //用qNode指向第k-1个元素

. ListNode qNode = first;

. for( int index=1; index< k-1 && qNode != null; index&#;&#; )

. qNode = qNode.next;

. if( qNode == null || qNode.next == null )

. return null;//不存在第k个元素

. pNode = qNode.next; //pNode指向第k个元素

. qNode.next = pNode.next; //从链表中删除第k个元素

. x = pNode.data;

. }

. return this;

. }

.

. // 清空链表

. public void Clear()

. {

. first = null;

. }

.

. }

}

unity4.5.3f3 和 Android的通信 packagecom.janlr.helloworld;importandroid.app.Activity;importandroid.content.Context;importandroid.content.Intent;importandroid.os.Bundle;importandroid.widget.Toast;importcom.unity3d.player.UnityPlaye

WWW封装共享 [复制链接] WWW其实很好用的。实测了,几百个的并发量毫无问题,相信,你的产品也没多少需要几百个的并发下载吧。WWW说白了就是个Unity3D对http请求的一个封装,

unity学习之摄像机的应用 unity学习,希望我的博客能给喜欢unity的朋友带来帮助今天学习了摄像机的应用,具体用途就是在游戏中,主角在行走时是远距离的跟随照射,当打怪物

本文链接地址:https://www.jiuchutong.com/biancheng/375805.html 转载请保留说明!

上一篇:C# Thread中函数如何设置参数(c#中thread的用法)

下一篇:unity4.5.3f3 和 Android的通信

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络