- 博客(28)
- 资源 (3)
- 收藏
- 关注
原创 android 国内无法下载leakcanary
buildscript {repositories {jcenter()mavenCentral()}dependencies {classpath 'com.android.tools.build:gradle:2.1.2'}}allprojects{repositories{jcenter()mavenCentral()}}a
2016-07-30 14:50:11
1500
原创 android写京东首页
final GridLayoutManager gridManager = ((GridLayoutManager) manager); gridManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int posi
2016-04-15 12:22:24
1054
原创 Java异常处理详解
1JAVA异常异常指不期而至的各种状况,如:文件找不到、网络连接失败、内存越界等。异常是一个事件,它发生在程序运行期间,干扰了正常的指令流程。Java通过API中Throwable类的众多子类描述各种不同的异常。因而,Java异常都是对象,是Throwable子类的实例,描述了出现在一段编码中的错误条件。当条件生成时,错误将引发异常。Java异常类层次结构图:这里需
2016-03-09 13:34:55
630
转载 String、StringBuffer与StringBuilder之间区别
String对象是不可改变的,每次使用String类中的方法时,都要在内存中创建一个新的字符串对象,这就需要为该新对象分配新的空间。在需要对字符串执行重复修改的情况下,与创建新的String对象相关的系统开销可能会非常昂贵。如果要修改字符串而不创建新的对象,则可使用StringBuilder类。对于String类我就不想举例了,使用的很普遍。对于像我这样的初学者来说,StringBuilder
2016-03-09 11:17:29
393
原创 内核概念-内核
1.R3和R0 用户模式和内核模式当我们开始一个应用层的程序,操作系统惠威改程序分配一个一个私有的虚拟地址空间和私有句柄表。因为地址空间是私有的,所以一个应用程序不能改变其他的应用程序的数据,每个应用程序都是独立的,当一个应用程序crash了,这个崩溃也仅限于这个程序,其他程序不会受影响。在内核中运行的代码共享一个虚拟地址空间,这意味着内核驱动并不是与操作系统和其他驱动是相互独立的,当
2015-08-11 17:09:51
1438
原创 引用、指针的指针、指针的引用
代码不具备可用性,只是用来测试#include using namespace std;class myclass{public: myclass(){}; ~myclass(){};};void fun1(myclass* ptr){ cout<<"调用fun1"<<endl; cout<<(myclass*)ptr<<endl; ptr = (myclass*)ma
2014-04-15 23:58:04
796
原创 KMP算法
#include using namespace std;void originalMatch(char* o,char* m){ int original = strlen(o); int match = strlen(m); if (match > original||match ==0||original == 0) { cout<<"length is incorrec
2014-04-12 15:11:48
648
原创 待修改,树的深度搜索和广度搜索
tree.h#ifndef RBTREE_H#define RBTREE_H#include #include #include #include #include using namespace std;templatestruct Node{ int item; Node* parent; Node* left; Node* right;};templat
2014-04-09 23:53:10
801
原创 时间复杂读为n的排序
排序年龄的算法//复杂度为On的排序算法#include#include using namespace std;const int oldestage=99;void OnSort(vector &v1){ if(v1.size()==0)return; vector v2(oldestage+1,0); for (auto i =0;i<v1.size();i++)
2014-03-31 23:51:37
651
原创 3.去除字符串中重复字符,保证每个字符只出现一次
//Design an algorithm and write code to remove the duplicate characters in a string //without using any additional buffer NOTE: One or two additional variables are fine // An extra copy of the array
2014-03-31 22:57:15
2001
原创 2.倒置字符串(这里第二个倒置出现问题不知道怎么解决)
//倒置字符串#include using namespace std;//倒置原字符串void reverse1(char * s){ if (s) { char temp; char * end=s; while (*end)//记住这里end只表示一个字符 { end++; } --end; while (s<end) { temp
2014-03-31 20:33:12
754
原创 1.确定一个字符串每个字符都是独一无二的
//Implement an algorithm to determine if a string has all unique characters What if //you can not use additional data structures?#include #include using namespace std;//适合所有ascii字符bool uniquech
2014-03-31 16:14:53
1126
原创 线程之路六:读者写者的问题
//有一个写者很多读者,多个读者可以同时读文件,但写者在写文件时不允许有读者在读文件,同样有读者在读文件时写者也不去能写文件。#include #include #include CRITICAL_SECTION gcs,buffer;HANDLE readerover,writerover;int m=0;//读者数量BOOL SetConsoleColor(WORD wAtt
2014-03-29 21:23:17
741
原创 线程之路五:消费者生产者
一个生产者,10个消费者,4个缓冲区//有一个生产者在生产产品,这些产品将提供给若干个消费者去消费,为了使生产者和消费者能并发执行,//在两者之间设置一个具有多个缓冲区的缓冲池,生产者将它生产的产品放入一个缓冲区中,消费者可以从缓冲区中取走产品进行消费,//显然生产者和消费者之间必须保持同步,//即不允许消费者到一个空的缓冲区中取产品,也不允许生产者向一个已经放入产品的缓冲区中再次
2014-03-26 20:52:52
770
原创 算法导论:第一讲:插入排序和归并排序
从今天开始每天至少一个算法开始写博客算是自己对自己的一个监督吧!只写代码,不讲原理!有问题自己查,也希望大家能给我改错!所有代码在VS2010均调试通过!顺便推荐大家一款软件Visual Assist 10.8.2029 (General Release)插入排序: 归并排序:#include #include using namespace std;vec
2014-03-25 23:44:09
692
原创 线程之路之四:进程同步线程互斥
信号量:#include #include#include HANDLE semaphore;CRITICAL_SECTION b;int num;unsigned int __stdcall ThreadFun(PVOID pm){ int m=*((int*)pm); ReleaseSemaphore(semaphore,1,NULL); Ent
2014-03-25 15:46:15
597
原创 线程之路三:设置时间和互斥量mutex
上一节中,我们用CriticalSection方法得到了连续数,其实这主要是CriticalSection所包含的区域与前面的原子操作有类似的功能。但是前面原子的操作没有得到连续的是因为cout部分和原子操作不是连续的,在cout之前有可能有多次的原子操作 所以不是连续的,这个CriticalSection能把cout和++都包含成原子操作。下面我们看下CreateEvent的两个细小的差别
2014-03-25 15:00:26
866
原创 写一些结构体的代码(stack,queue,现行表,二叉树,图模板 持续更新……)
栈结构:heap.h#ifndef HEAP_H#define HEAP_H#include templateclass Heap{private: static const int max =50; T heap[max]; int top;public: Heap(); ~Heap(){}; bool Isempty(); b
2014-03-25 12:52:57
980
原创 冒泡排序(正宗点吧)
#include #include using namespace std;void swap(int & a,int & b){ a=a+b; b=a-b; a=a-b;}vector & bubbleSort(vector & v){ int n=v.size(); int flag; for(auto i =0;i < n;i++)
2014-03-24 23:40:22
682
原创 希尔排序
#include #include using namespace std;void swap(int & a,int & b){ a=a+b; b=a-b; a=a-b;}void print(vector & v){ vector::iterator pos; for(pos = v.begin();pos!=v.end();pos++)
2014-03-24 23:05:48
559
原创 选择排序(非冒泡排序)我也不懂了 第一个算冒泡排序了吗?
#include #include using namespace std;void swap(int & a,int & b){ a=a+b; b=a-b; a=a-b;}vector & bubbleSort(vector & v){ int n=v.size(); for(auto i =0;i < n;i++) for(auto
2014-03-24 19:15:31
935
原创 线程之路二:线程原子操作和线程CriticalSection操作
一原子操作:即是那种运行了不把这条语句执行完就不会把计算机控制权交给另一个线程控制#include #include#include int num=0;unsigned int __stdcall ThreadFun(PVOID pm){ InterlockedIncrement((LPLONG)&num); //原子操作 //std::cout<<"第
2014-03-24 16:20:51
688
原创 线程之路一:CreateThread()和-beginthreadex()
第一部分代码 线程传值线程返回pid#include #include //传值 返回进程idDWORD WINAPI ThreadFun(LPVOID pm){ std::cout<<*((int*)pm)<<"\nhello world!!!\n"<<GetCurrentThreadId()<<std::endl; return 0;}int main
2014-03-24 14:07:31
709
原创 快速排序实现
#include #include #include using namespace std;//两个版本void show(vector &v){ vector::iterator pos; for(pos = v.begin();pos != v.end();pos++) cout<<*pos<<" "; cout<<endl;}//第一个
2014-03-22 18:36:29
682
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人