JDK
文章平均质量分 78
key2value
爱历史 爱IT于规范下做到最好
展开
-
Java的Arrays部分算法详解
java的java.util.Arrays工具类提供了很多有用的方法,而且有很多方法是重载(overload)的,现在来研究一些部分算法的应用。1. 二分查找double数组public static int binarySearch(double[] a, int fromIndex, int toIndex,原创 2015-01-09 22:11:50 · 711 阅读 · 0 评论 -
DualPivotQuicksort解读
java.util.Arrays里面使用了java.util.DualPivotQuicksort作为主要的排序实现。根据JDK注释,/** * This class implements the Dual-Pivot Quicksort algorithm by * Vladimir Yaroslavskiy, Jon Bentley, and Josh Bloch. The algor原创 2015-01-10 09:53:38 · 2976 阅读 · 0 评论 -
Java Hashtable的实现
先附源码:/* * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * *原创 2014-12-30 16:39:56 · 1594 阅读 · 0 评论 -
摩根斯坦利面试——Java多线程
今天上午,参加大摩的面试,自觉失败,记录一下过程。面试官看着简历,并没有就简历提问,整个过程都在问java多线程的问题。1. ReentrantLock,作为可重入锁,怎么理解“可重入”二字,有没有不可重复的锁?我:获得对象锁的线程能够再次获得对象锁,访问对象……被鄙视了,后来想想,应该把递归这种场景说下;2.生产者-消费者模型怎么实现?我:使用synchronized或者Lo原创 2015-04-03 17:03:23 · 3046 阅读 · 0 评论 -
LRU Cache 暨LinkedHashMap源码阅读
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if原创 2015-05-06 19:23:36 · 840 阅读 · 0 评论 -
OSCache源码阅读(二)
前文LRU Cache 暨LinkedHashMap源码阅读提到了如何使用LinkedHashMap来实现一个LRU数据结构,今天在看OSCache代码算法部分的时候,就用到了该知识,what was done contributes what is done now。algorithm包是包含下列缓存过期策略的类: 下面重点介绍LRU和FIFO。LRUprivate Collection l原创 2015-05-07 11:51:17 · 1020 阅读 · 0 评论