惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
CERT Recently Published Vulnerability Notes
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
Stack Overflow Blog
Stack Overflow Blog
aimingoo的专栏
aimingoo的专栏
C
Check Point Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Tor Project blog
P
Proofpoint News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Latest news
Latest news
L
LINUX DO - 热门话题
罗磊的独立博客
T
Tenable Blog
The Hacker News
The Hacker News
美团技术团队
N
Netflix TechBlog - Medium
V
Vulnerabilities – Threatpost
阮一峰的网络日志
阮一峰的网络日志
Last Week in AI
Last Week in AI
博客园 - 司徒正美
Jina AI
Jina AI
Cyberwarzone
Cyberwarzone
云风的 BLOG
云风的 BLOG
S
Secure Thoughts
Cloudbric
Cloudbric
S
Security @ Cisco Blogs
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Security Blog
Microsoft Security Blog
Spread Privacy
Spread Privacy
U
Unit 42
雷峰网
雷峰网
C
CXSECURITY Database RSS Feed - CXSecurity.com
Webroot Blog
Webroot Blog
爱范儿
爱范儿
博客园 - 【当耐特】
Know Your Adversary
Know Your Adversary
P
Privacy International News Feed
P
Palo Alto Networks Blog
Google Online Security Blog
Google Online Security Blog
The Last Watchdog
The Last Watchdog
博客园 - 聂微东
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
F
Full Disclosure
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Security Affairs
Project Zero
Project Zero

博客园 - 过河卒A

.net控件开发(十一)之.net设计期功能 第一部分 左中右3栏布局中最先显示中栏内容的方法 IE中z-index BUG IE中IMG元素上应用padding的奇特bug 关于String、Function、Array的属性和用法 lisp入门 函数式编程让JS更优美 函数式JavaScript编程指南 JavaScript 随笔汇集 如何杜绝iframe挂马 怎么用javascript进行拖拽(转摘) .net的幕后英雄 (转摘) 微软计划2008年初发布Windows Server2008 微软:将以SQL Server授权拉拢甲骨文客户 微软发布SQL Server 2008测试版 明年上市 微软MSN推出新一代Live服务 能离线编辑博客 谷歌发布GPhone 创始人亲自上阵 微软刘振宇:Windows live for Mobilo带来新机遇 微软招募经理 欲开发下一代照片视频共享服务
javascript实现的数据结构
过河卒A · 2007-12-07 · via 博客园 - 过河卒A

此例是javascript来建立链表。。
并对此进行了排序。。

还可以在GenericList一般链表上进行扩展。
实现各种排序及增,删,改结点。。



<script>
function Node(){
  
this.data=null;
  
this.next=null;
}


function GenericList(){
  
this.head=null;
  
this.current=null
  
//打出所有的链表结点
  this.print= function(){
  
this.current=this.head;
   
while(this.current!=null){
      alert(
this.current.data);
      
this.current=this.current.next;
    }

  
  }
,
  
//建立链表
  this.addHead =function(t){
      
  
      
var node=new Node();
      node.data
=t;
      node.next
=this.head;
      
this.head=node;
 
  }

  
  

}



function SortList(){
//冒泡排序链表 
this.BubbleSort=function()
   
{
     
if(this.head==null||this.head.next==null)
     
{
        
return ;
     }

    
var swapped;
    
do{
    
     
this.previous=null;
     
this.current=this.head;

     
var swapped=false;
     
while(this.current.next!=null)
      
{
       
       
if(this.current.data-this.current.next.data>0)
        
{
       
        
var tmp=this.current.next;
        
this.current.next=this.current.next.next;
        tmp.next
=this.current;
        
if(this.previous==null)
            
{
               
this.head=tmp;
            }

         
else
           
{
               
this.previous.next=tmp;
           }

          
this.previous=tmp;
          swapped
=true;
          
       
       }

       
else
        
{
        
        
this.previous=this.current;
        
this.current=this.current.next;
        
        }

     
     }

     
      
    
    }
while(swapped);
   
   }


}


SortList.prototype
=new GenericList();


(
function Main(){
 
var sl=new  SortList();
 
for(var i=0;i<arguments.length;i++)
 
{sl.addHead(arguments[i]);
 }

 alert(
"未排序的链表");
 sl.print();
 sl.BubbleSort();
  alert(
"已排序的链表  从小到大");
 sl.print();

}
)("1","2","3","4")
</script>