原创 muduo源碼分析:ThreadLocalSigleton類
單例+特定數據 // Singleton 所管理的對象是 ThreadLocal<Test> ,ThreadLocal<Test> 在進程內是單例,所有線程共一個ThreadLocal<Test> 實例 Singl
原创 muduo源碼分析:reactor模型封裝
圖中FileDescriptor、socket都不是類 EventLoop:loop --》poller::loop --》pollPoller ::loop 或者epollpoller::poll,循環等待io事件發生,發生後E
原创 不用加減乘除實現加法
思路: 不用加減乘除,那隻能用位運算。 1.兩個數a,b相加,二進制如果不考慮進位 0+0 得 0 ;1+0 得 1;1+1 得 0 =》 其實就是異或^ 得到 tmp1 2.考慮進位,只有 1+1 的位置上會導致前一位(左邊)進位
原创 leetcode :Candy
There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these child
原创 C++ 數組引用傳遞與指針傳遞
#include <iostream> #include <string> #include <string.h> using namespace std; class SourceFile { public: temp
原创 JAVA Web servlet 與監聽器
Servlet生命週期 1.servlet可以在web.xml 配置映射路徑 <servlet> <servlet-name>welcome</servlet-name> <servlet-class>o
原创 C語言編程技巧-signal(信號機制) 與中斷
用戶態到內核態切換途徑: 1:系統調用 2:中斷 3:異常 中斷類型分爲如下兩大類: 一、強迫性中斷:正在運行的程序所不期望的,來自硬件故障或外部請求。 1、I/O 中斷:來自外部設備通道
原创 java的hashCode與equals以及HashMap元素確定
HashMap的key和value存儲的都是各自的引用,而不會拷貝。 hashCode 相同則在hashMap中存儲的槽位(數組中的位置)相同,此時會調用equals判斷兩個是不是同一對象,如果equals返回true就當做一個對象。儘量
原创 java虛擬機與jvm內存模型
1.Java虛擬機本質與編譯器由來 Java虛擬機jvm(一個c/c++程序而已,當然也有其他語法實現的)其實是一個進程虛擬機--上面跑進程的(,普通服務器虛擬機是跑操作系統的),啓動一個java程序就是啓動一個java虛擬
原创 leetcode 8 String to Integer
Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a ch
原创 leetcode 1. Two Sum
題目 Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may
原创 leetcode:154. Find Minimum in Rotated Sorted Array II
Follow up for "Find Minimum in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time
原创 泛型中? super T和? extends T的區別
原文鏈接 李璟([email protected]) 經常發現有List<? super T>、Set<? extends T>的聲明,是什麼意思呢?<? super T>表示包括T在內的任何T的父類,<
原创 spring bean 入門
參考:慕課網http://www.imooc.com/video/3668 一.spring 注入方式 spring注入是指實例化某個類時,對該類的成員變量賦值 spring有兩種注入方式(即兩種賦值方式): 1.構造器注入:在構造函數中
原创 java單元測試junit
轉自:http://blog.csdn.net/typa01_kk/article/details/8513548 推薦: http://my.oschina.net/pangyangyang/blog/144495 http://blo