孤独的猫

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

2012年5月12日

摘要: 转自:http://blog.sina.com.cn/s/blog_537bb50a010000iu.html续四:====对1-300000个整数随机放到数组中,为测试做准备====/** @(#)RandomNum.java* * Title: This class is to define the RandomNum.* Description: This file is the assignment of Algorithms.* @copyright (c) OpenSource* @author Bobby Yang* @tester Bobby Yang* @version 1. 阅读全文
posted @ 2012-05-12 21:05 孤独的猫 阅读(181) 评论(0) 推荐(0) 编辑

摘要: 转自:http://blog.sina.com.cn/s/blog_537bb50a010000it.html续三:====红黑树操作的实现,插入、删除、查找 (三)==== private Node getSuccessor(Node node){ if (node.rightChild != nil) return getMin(node.rightChild); Node y = node.parent; while((y != nil) && (y.rightChild == node)){ node = y; y = y.parent; } return y; } . 阅读全文
posted @ 2012-05-12 21:04 孤独的猫 阅读(143) 评论(0) 推荐(0) 编辑

摘要: 转自:http://blog.sina.com.cn/s/blog_537bb50a010000is.html续二:====红黑树操作的实现,插入、删除、查找 (二)====private void leftRotate(Node node){ Node y; y = node.rightChild; node.rightChild = y.leftChild; if(y.leftChild != nil) y.leftChild.parent = node; y.parent = node.parent; if (node.parent == nil) this.se... 阅读全文
posted @ 2012-05-12 21:03 孤独的猫 阅读(121) 评论(0) 推荐(0) 编辑

摘要: 转自http://blog.sina.com.cn/s/blog_537bb50a010000ir.html续一====红黑树操作的实现,插入、删除、查找 (一)====/** @(#)Rbtree.java* * Title: This class is to define the RBtree.* Description: This file is the assignment of Algorithms.* @copyright (c) OpenSource* @author Bobby Yang* @tester Bobby Yang* @version 1.00* @time 200 阅读全文
posted @ 2012-05-12 21:02 孤独的猫 阅读(163) 评论(0) 推荐(0) 编辑

摘要: 红黑树的实现Java代码(一)(2005-11-06 16:32:44)转自:http://blog.sina.com.cn/s/blog_537bb50a010000ip.html我被Sina烦死了,刚才写的全挂了。这几天一直在忙这个作业,好不容易在今天写完了,鉴于辛苦的历程,网上基本没有什么有参考价值的东西,而国外的网站上基本是Applet,也不是我想要的,关于这个算法的思想教课书里面都有,我这是只是对其用java实现。希望对您有参考价值。以下是要写得文章结构:======算法的说明文档摘录============算法的Java实现====== ====红黑树的结点类==== ====红黑 阅读全文
posted @ 2012-05-12 21:01 孤独的猫 阅读(604) 评论(1) 推荐(0) 编辑

摘要: java的锁机制现行的有synchronized和Lock。synrhronized关键字简洁、清晰、语义明确。其应用层的语义是可以把任何一个非null对象作为”锁”,当synchronized作用在方法上时,锁住的便是对象实例(this);当作用在静态方法时锁住的便是对象对应的Class实例,因为Class数据存在于永久带,因此静态方法锁相当于该类的一个全局锁;当synchronized作用于某一个对象实例时,锁住的便是对应的代码块。synrhronized锁主要通过Lock-Free的队列,放弃了些公平性,通过自旋锁提高了瞬时的吞吐量。 下面是JAVA模拟银行账户存储和转移的实例: 1.. 阅读全文
posted @ 2012-05-12 20:53 孤独的猫 阅读(295) 评论(0) 推荐(0) 编辑

摘要: 在多线程中可以很方便的控制多个弹跳球的移动,当球体碰到窗体边界便折回。用Thread.start启动一个新的线程。 1 /** 2 @version 1.32 2004-07-27 3 @author Cay Horstmann 4 */ 5 6 import java.awt.*; 7 import java.awt.event.*; 8 import java.awt.geom.*; 9 import java.util.*; 10 import javax.swing.*; 11 12 /** 13 Shows an animated bounci... 阅读全文
posted @ 2012-05-12 20:46 孤独的猫 阅读(503) 评论(0) 推荐(0) 编辑