自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(44)
  • 资源 (2)
  • 收藏
  • 关注

原创 Android开源框架Universal-Image-Loader学习三——UsingFreqLimitedMemoryCache源码阅读

Universal-Image-Loader的内存缓存策略1. 只使用的是强引用缓存 LruMemoryCache(这个类就是这个开源框架默认的内存缓存类,缓存的是bitmap的强引用)2.使用强引用和弱引用相结合的缓存有UsingFreqLimitedMemoryCache(如果缓存的图片总量超过限定值,先删除使用频率最小的bitmap)LRULimitedM

2015-04-30 15:16:25 1153

原创 leetcode-27 Remove Element

问题描述:Givenan array and a value, remove all instances of that value in place and returnthe new length.The order of elements can be changed. It doesn'tmatter what you leave beyond the new

2015-04-29 16:18:19 850

原创 leetcode-26 Remove Duplicates from Sorted Array

问题描述:Givena sorted array, remove the duplicates in place such that each element appearonly once and return the new length.Do not allocate extra space for another array, youmust do this i

2015-04-29 16:17:31 726

原创 leetcode-22 Generate Parentheses

问题描述:Given n pairs of parentheses, write a function to generate allcombinations of well-formed parentheses.For example, given n = 3, a solution setis:"((()))","(()())", "(())()", "()((

2015-04-28 16:32:16 889

原创 leetcode-21 Merge Two Sorted Lists

问题描述:Merge two sorted linked lists and return it as a new list. The new listshould be made by splicing together the nodes of the first two lists.问题分析:算法本身不难,比较两个链表头节点的值,取较小者赋给result

2015-04-28 08:42:42 778

原创 Android开源框架Universal-Image-Loader学习二——LruMemoryCache源码阅读

Universal-Image-Loader的内存缓存策略1. 只使用的是强引用缓存 LruMemoryCache(这个类就是这个开源框架默认的内存缓存类,缓存的是bitmap的强引用)2.使用强引用和弱引用相结合的缓存有UsingFreqLimitedMemoryCache(如果缓存的图片总量超过限定值,先删除使用频率最小的bitmap)LRULimite

2015-04-28 08:37:25 2280

原创 Android之BroadcastReceiver标准用法

BrocastReceiver用法:1、继承BroadcastReceiver类2、重写onReceive函数(见最下面代码)3、在Mainfest文件中注册receiver 自定义BrocastReceiver -->                              4、在Activity中启用BrocastRec

2015-04-27 15:22:58 953

原创 序列化Parcelable和Serializable接口的区别

一、Parcelable和Serializable接口简介1. Parcelable接口Interface for classes whose instances can be written to and restored from a Parcel。 Classes implementing the Parcelable interface must also have a s

2015-04-26 11:07:09 1527

原创 leetcode-17 Letter Combinations of a Phone Number

问题描述:Given a digitstring, return all possible letter combinations that the number couldrepresent.A mapping of digitto letters (just like on the telephone buttons) is given below.Input:Digi

2015-04-24 16:54:00 979

原创 Java交换值及中间缓存机制

实现交换int a,b的值的函数,C++可以采用引用或指针传递的方法,当Java不行;因为Java的参数传递机制与C++不同(http://blog.csdn.net/woliuyunyicai/article/details/44096043),如下方法均不能够实现:public void swap(int x, int y){ int temp = x;

2015-04-23 09:07:52 1042

原创 Android中的Handler消息机制

转自:http://blog.csdn.net/liuhe688/article/details/6407225在分析Android消息机制之前,我们先来看一段代码:public class MainActivity extends Activity implements View.OnClickListener { private TextView stateT

2015-04-23 08:51:26 959

原创 ListView优化总结

1、ListView中的Button会抢夺ListView的焦点,需要将Button设置为没有焦点。设置非常简单,只需要在xml的Button标签下加入一行:android:focusable=“false”代码就可以了。2、ListView的Adapter     主要分为ArrayAdapter、SimpleAdapter、SimpleCursorAdapter三类   

2015-04-21 14:52:34 1055

原创 并发和并行,异步与多线程区别

1、并发和并行的区别可由上图形象指出两者的区别:1)定义:并发:在操作系统中,是指一个时间段中有几个程序都处于已启动运行到运行完毕之间,且这几个程序都是在同一个处理机上运行,但任一个时刻点上只有一个程序在处理机上运行。并行:在操作系统中,一组程序按独立异步的速度执行,无论从微观还是宏观,程序都是一起执行的。来个比喻:并发和并行的区别就是一个人同时吃三个馒头和

2015-04-21 09:01:50 16383 10

原创 Android开源框架Universal-Image-Loader学习使用1

一、工作流程:1、当请求显示图片,调用ImageLoader.displayImage(),首先会    1)计算显示图片的尺寸大小    2)判断该图片是否已存在缓存中,若No,跳到步骤3,若Yes,跳到步骤9    3)判断图片是否已存在本地,若No,跳到步骤4;若Yes,跳到步骤6    4)判断图片允许存储在本地,若No,跳转到步骤6;若Yes,跳到步骤5

2015-04-20 16:49:20 1051

原创 Baidu笔试-01序列排序的交换次数

问题描述:问题分析:解法一:设置双指针,start,end;当data[start]=‘1’,data[end]=’0’时,表示需要进行交换,次数加1;否则data[end]=’1’则前移end指针;data[start]=‘0’则后移start指针;该算法仅需遍历一次解法二:先遍历一次计算字符数组中0的个数zero,再计算前zero个字符中1的个数,即是要交换到后面的

2015-04-20 14:37:23 1606

原创 hihocode-2月29

问题描述:时间限制:2000ms单点时限:1000ms内存限制:256MB描述给定两个日期,计算这两个日期之间有多少个2月29日(包括起始日期)。只有闰年有2月29日,满足以下一个条件的年份为闰年:1. 年份能被4整除但不能被100整除2. 年份能被400整除输入第一行为一个整数T,表示数据组数。之后每组数据包含两行。每一行格式为"month d

2015-04-20 14:22:58 1050

原创 Runnable,Callable,Thread,Future,FutureTask关系

1、Runnable和Callable的区别是:(1)Callable规定的方法是call(),Runnable规定的方法是run().(2)Callable的任务执行后可返回值,而Runnable的任务是不能返回值得(3)call方法可以抛出异常,run方法不可以(4)运行Callable任务可以拿到一个Future对象,表示异步计算的结果。它提供了检查计算是否完成的方法,以等待

2015-04-17 10:11:45 1005

原创 Java多线程-并发和并行

1、并发和并行的区别可由上图形象指出两者的区别:1)定义:并发:在操作系统中,是指一个时间段中有几个程序都处于已启动运行到运行完毕之间,且这几个程序都是在同一个处理机上运行,但任一个时刻点上只有一个程序在处理机上运行。并行:在操作系统中,一组程序按独立异步的速度执行,无论从微观还是宏观,程序都是一起执行的。来个比喻:并发和并行的区别就是一个人同时吃三个馒

2015-04-17 10:09:22 1019

原创 设计模式之Builder模式(建造者模式)

部分转载:http://www.cnblogs.com/BeyondAnyTime/archive/2012/07/19/2599980.html一个人活到70岁以上,都会经历这样的几个阶段:婴儿,少年,青年,中年,老年。并且每个人在各个阶段肯定是不一样的呀,我觉得可以说世界上不存在两个人在人生的这5个阶段的生活完全一样,但是活到70岁以上的人,都经历了这几个阶段是肯定的。实际上这是一

2015-04-15 16:02:59 1752

原创 leetcode-19 Remove Nth Node From End of List

问题描述:Given a linkedlist, remove the nth node fromthe end of list and return its head.For example,   Given linked list: 1->2->3->4->5,andn = 2.   After removing the second node from the end

2015-04-15 14:08:32 744

原创 Android之ViewStub

转自:http://www.cnblogs.com/lwbqqyumidi/p/4047108.htmlViewStub是Android布局优化中一个很不错的标签/控件,直接继承自View。虽然Android开发人员基本上都听说过,但是真正用的可能不多。ViewStub可以理解成一个非常轻量级的View,与其他的控件一样,有着自己的属性及特定的方法。当ViewStub使用在布局文件

2015-04-14 10:27:25 928

原创 剑指Offer-题16 反转链表(Java)

问题描述:定义一个函数,输入一个链表的头结点,反转该链表并输出翻转后链表的头结点;问题分析:为避免反转时,当前节点的next指针指向前驱lastNode,而无法继续索引其后继nextNode,故在遍历过程中,注意要同时记录其前驱与后继;同时注意鲁棒性:如输入链表头指针为null或者只有一个节点的情况;代码:/*public class ListNode {

2015-04-13 16:15:48 842

原创 Java数组

1、注意:int[] array = newint[-1];这样定义仍可以编译通过,只是在运行时会抛出java.lang.NegativeArraySizeException异常,这是一个运行时异常,通俗讲就是代码不运行到这一行就不会出现问题。(注:int[] array = newint[0];是合法的)但类似的定义如int i[3][-1]则是会在编译期报错

2015-04-13 14:30:48 805

原创 Java异常

0、C++异常处理机制基于Ada,Java异常处理则是基于C++1、Java异常类层次结构所有异常类都继承自Throwable类,并有两个主要分支:Error和Exception;Error类描述Java运行时系统的内部资源和资源耗尽错误,表示编译时和系统错误;Exception类又包括两个主要分支:RuntimeException;和其他异常(如IOException

2015-04-13 14:30:00 841

原创 leetcode-18 4Sum

问题描述:Givenan arrayS of n integers, are there elements a, b, c,and d in S such that a + b + c +d =target? Find all unique quadruplets in the array which gives the sum of target.Note:

2015-04-12 16:17:27 876

原创 Java方法重载与重写(静态分派与动态分派)

Java面向对象3个基本特征:继承、封装和多态;多态主要体现在重载和重写;1、静态分派静态分派与重载有关,虚拟机在重载时是通过参数的静态类型,而不是运行时的实际类型作为判定依据的;静态类型在编译期是可知的;1)基本类型以char为例,按照char>int>long>double>float>double>Character>Serializable>Object>...(变

2015-04-12 10:40:33 2139

原创 leetcode-16 3Sum Closest

问题描述:Given an arrayS of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would

2015-04-12 10:38:53 886

转载 浅复制与深复制

浅复制与深复制1.浅复制与深复制概念⑴浅复制(浅克隆)被复制对象的所有变量都含有与原来的对象相同的值,而所有的对其他对象的引用仍然指向原来的对象。换言之,浅复制仅仅复制所考虑的对象,而不复制它所引用的对象。 ⑵深复制(深克隆)被复制对象的所有变量都含有与

2015-04-12 10:35:16 779

原创 leetcode-14 Longest Common Prefix

问题描述:Write a function to find the longest common prefix stringamongst an array of strings.问题分析:代码:public class Solution { public String longestCommonPrefix(String[] strs) {

2015-04-10 20:40:49 766

原创 leetcode-13 Roman to Integer

问题描述:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to3999.问题分析:{'M','D','C','L','X','V','I'};分别对应{1000, 500, 100, 50, 10, 5, 1};当出

2015-04-10 20:15:23 773

原创 Eclipse查看android.support.v4中的源码

1.ADT会自动将android.support.v4.jar添加到项目中的libs中android-support-v4.jar.properties配置文件是需要自己创建的在该文件中写入SDK中extras/android/support/v4/src即android.support.v4的路径,且注意要//号,并加上前面的src =如图所示:关闭工程并重新打开,则

2015-04-10 14:24:53 835

原创 Java虚拟机类加载机制

1、定义虚拟机把描述类的数据从Class文件加载到内存,并对数据进行校验、转换解析和初始化,最终形成可以被虚拟机直接使用的Java类型,这就是虚拟机的类加载机制。2、概述1)在Java语言中,类型的加载、连接和初始化过程都是在程序运行期间完成的;Java天生具有的动态扩展的特性就是依赖运行期动态加载和动态连接这个特点实现的。2)类的生命周期:加载(Loading)->验证(Veri

2015-04-09 21:37:21 782

原创 leetcode-200 Number of Islands

问题描述:Given a 2dgrid map of'1's (land) and'0's (water),count the number of islands. An island is surrounded by water and is formed byconnecting adjacent lands horizontally or vertically

2015-04-09 16:31:02 1060

原创 04-08 leetcode-12 Integer to Roman

问题描述:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to3999.问题分析:类似于十进制,从高位进行计算即可代码:public class Solution { public String intTo

2015-04-08 15:04:29 727

原创 Java中子类父类变量访问问题

变量(实例变量、类变量、常量)及类方法均与编译时类型相关实例方法与运行时类型相关(故而产生多态)class A{    public static int h = 10;    public int n = 10;    public static final int m = 10;       public static void put()

2015-04-07 20:58:03 1396

原创 leetcode-8 String to Integer (atoi)

问题描述:Implementatoi to convert a string to an integer.Hint: Carefullyconsider all possible input cases. If you want a challenge, please do not seebelow and ask yourself what are the p

2015-04-07 16:35:07 845

原创 Java变量初始化问题

class AMMM{      public final static  int CHANG = 10;//注意并不是修饰符为final+static的域就是常量,                                        //比如:final static int A = Random.nextInt();它并非编译期常量    publ

2015-04-07 15:32:11 751

原创 leetcode-11 Container With Most Water

问题描述:Givenn non-negative integers a1,a2, ...,an, where each represents a pointat coordinate (i, ai).n vertical lines aredrawn such that the two endpoints of line i is at (i,ai) and (

2015-04-07 11:00:04 843

原创 leetcode-9 Palindrome Number 回文数字

问题描述:Determine whether an integer is a palindrome. Do thiswithout extra space.click to showspoilers.Some hints:Could negative integers be palindromes? (ie, -1)If yo

2015-04-03 21:08:15 736

原创 leetcode-7 Reverse Integer 十进制数字逆序输出

问题描述:Reverse digitsof an integer.Example1: x =123, return 321Example2: x =-123, return -321问题分析:反转算法并不难,关键在于对溢出问题的考虑代码:public class Solution { public int reverse(int x) {

2015-04-03 16:54:46 1150

使用RadioGroup及Fragment来实现底部Tab效果

使用RadioGroup及Fragment来实现底部Tab效果

2015-11-06

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除