2013年7月15日

Hashtalbe JAVA实现

摘要: 总得来说就是每个哈希表都保存了一个Entry数组,然后每个Entry其实是存放碰撞的一个链,其中Entry类部分代码实现是:/** * Hashtable collision list. */ private static class Entry implements Map.Entry { int hash; K key; V value; Entry next; protected Entry(int hash, K key, V value, Entry next) { this.hash = hash; t... 阅读全文

posted @ 2013-07-15 19:04 brave_bo 阅读(259) 评论(0) 推荐(0)

2013年7月13日

HashMap 的java实现.

摘要: 第一篇文章第二篇文章处理冲突的方法开放定址法链地址法再哈希法我一直对HashMap的内部结构很好奇,看了源码之后发现他是用散列实现的,即基于hashcode 大体思想是这样的 1. 首先建立一个数组用来存取数据,假设我们定义一个Object[] table用来存取map的value这个很容易理解,key存在哪里呢?暂时我不想存储key 2.获得key的hashcode经过一定算法转成一个整数 index,这个index的取值范围必须是0=>> 20) ^ (h >>> 12); return h ^ (h >>> 7) ^ (h >> 阅读全文

posted @ 2013-07-13 05:36 brave_bo 阅读(267) 评论(0) 推荐(0)

2013年7月12日

面试总结之-查找算法分析

摘要: 二分法 static int BinarySearch(int[] a,int tar){ //n是最后一个下标,tar是要找的数 int i = 0, j = a.length-1; while(i tar) j = mid-1; else i = mid+1; } return -1; }上面就是一个典型的二分法. 核心思想是: 不断的化小值所在的范围。二分法有几个需要关注的点:1. mid = i + (j-i)/2. 防止越界.2. return i, or j, or mid.3.... 阅读全文

posted @ 2013-07-12 04:01 brave_bo 阅读(385) 评论(0) 推荐(0)

2013年7月4日

11. Dom Extensions.

摘要: 1.the querySelector() var body = document.querySelector("body"); // get body element var myDiv = document.querySelector("#myDiv"); // get ID of "myDiv" var selected = document.querySelector(".selected") // get class of "selected" var img = document.b 阅读全文

posted @ 2013-07-04 05:09 brave_bo 阅读(215) 评论(0) 推荐(0)

2013年7月1日

frond end 总结

摘要: problems with prototypes.all instance get the same property values by default.the main problem comes with their shared nature for example : person1.friends array push a new stuff. person2.frend also change.constructor vs instance vs prototypeeach constructor has a prototype object that points back . 阅读全文

posted @ 2013-07-01 18:42 brave_bo 阅读(179) 评论(0) 推荐(0)

2013年6月30日

frond end 找工作 随笔

摘要: What happens when you click on a link and get the web page? meaning what's the process behind that?anwser:1. Checks link's URL part. If not empty take that URL to be feteched.2. browser checks cache; if requested object is in cache and is fresh, skip to #93. browser asks OS for server's 阅读全文

posted @ 2013-06-30 05:03 brave_bo 阅读(247) 评论(0) 推荐(0)

2013年6月13日

abstract vs interface

摘要: interfaces can have no state or implementation,data members must be public final statica class that implements an interface must provide an implementation of all the methods of that interfaceabstract classes may contain state (data members) and/or implementation (methods)abstract classes can be inhe 阅读全文

posted @ 2013-06-13 08:10 brave_bo 阅读(277) 评论(0) 推荐(0)

How Garbage Collection Really Works

摘要: Java Memory ManagementJava Memory Management, with its built-in garbage collection, is one of the language’s finest achievements. It allows developers to create new objects without worrying explicitly about memory allocation and deallocation, because the garbage collector automatically reclaims memo 阅读全文

posted @ 2013-06-13 07:53 brave_bo 阅读(194) 评论(0) 推荐(0)

public private protected 区别

摘要: 1、public:public表明該數據成員、成員函數是對所有用戶開放,所有用戶都可以直接進行調用2、private:private表示私有,私有的意思就是除了class自己之外,任何人都不可以直接使用,私有财产神圣不可侵犯嘛,即便是子女,朋友,都不可以使用。3、protected:protected对于子女、朋友来说,就是public的,可以自由使用,没有任何限制,而对于其他的外部class,protected就变成private。作用域 當前類 同一package 子孫類 其他packagepublic √ √ √ √protected √ √ ... 阅读全文

posted @ 2013-06-13 07:48 brave_bo 阅读(535) 评论(0) 推荐(0)

一个简单的死锁小程序

摘要: public class TestDeadLock implements Runnable{ public int flag = 1; static Object o1 = new Object(), o2 = new Object(); public void run() { System.out.println("flag=" + flag); if(flag == 1) { synchronized(o1) { try ... 阅读全文

posted @ 2013-06-13 07:29 brave_bo 阅读(221) 评论(0) 推荐(0)

导航