• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: 小 中 大 | 推荐给好友 上一篇 | 下一篇

一个Javascript链表

发布: 2007-5-25 23:40 | 作者: 佚名 | 来源: 互连网 | 查看: 23次 | 进入软件测试论坛讨论

领测软件测试网 function Entry(next, data)
{
       this.next = next
       this.data = data
}

function Iterator(node)
{
       this.cousor = node
       this.hasNext = function ()
       {
               return (this.cousor.next != null);
       }
       this.next = function ()
       {
               var rt = this.cousor.next
               this.cousor = this.cousor.next
               return rt.data
       }
}

function LinkedList()
{
       this.head = new Entry(null, null)
       this.size = function ()
       {
               var size = 0
               if (this.head == null)
               {
                       return size
               }

               var p = this.head.next
               for(; p!=null; p = p.next)
               size++;
               return size;
       }

       this.clear = function ()
       {
               this.head = null
       }

       this.getNode =  function (idx)
       {
               var pos = -1;

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/