原创 動態規劃算法之強盜搶劫
題目:強盜搶劫一排房間,每個房間都藏着一定數量的錢,不能搶劫兩個相鄰的房間,要求搶的錢最多 數組如:[2,7,9,3,1]
原创 muduo之CountDownLatch.cc
CountDownLatch用線程同步的。 CountDownLatch.h // Use of this source code is governed by a BSD-style license // that c
原创 muduo之LogFile
muduo之LogFile,LogFile是控制日誌怎麼和文件打交道,其中包含常用的對日誌處理的一些操作。AsyncLogging異步日誌需要調用LogFile的接口將日誌寫入文件,其中包含了AppendFile類,相當於
原创 muduo之LogStream
LogStream.h // Use of this source code is governed by a BSD-style license // that can be found in the License
原创 linux可讀可寫爲啥設置421
學過linux的人都知道,可讀:4 可寫:2 可執行:1 一個文件如果可讀可寫可執行的值就是7=4+2+1,但是爲啥要這樣設置,看一下它們的二進制。 4 : 0000 0100
原创 redis之adlist.c
adlist是redis實現的雙端鏈表,這個雙端鏈表和數據結構中的雙鏈表類似。雙端鏈表list有一個指向鏈表和一個指向鏈表尾的指針,list還包括一些函數指針。 如:void *(*dup)(void *ptr);
原创 muduo之Atomic
Atomic是muduo原子操作的實現類。 Atomic.h // Use of this source code is governed by a BSD-style license // that can be f
原创 redis之zskiplist
跳躍表(zskiplist)在redis中作爲sorted set的底層實現,今天來學習一下。 /* ZSETs use a specialized version of Skiplists */ typedef st
原创 異步調用之內存拷貝
某次寫一個庫給前端調用,前端在傳入一個分配的內存塊給庫裏面有數據,然後庫通過消息隊列的方式將數據存儲起來,發給服務端,但服務端收到的數據出現概率性亂碼。 服務端打印收到的數據異常,客戶端打印數據發現,發
原创 常見算法之分支界定
test
原创 常見算法之窮舉法
test
原创 linux pread/pwrite
pread/pread操作是原子性的,seek和read/write操作一起完成,適合用於多線程中。 mapan@mapan-virtual-machine:~/c++$ cat test.txt hello worl
原创 常用類型所佔字節數
32位下,int、long、long long、__int64所佔字節數和取值範圍 字節數 char: 1字節(8位) int: 4字節 (32位,取值範圍 -2^31 ~ 2^31-1) unsigned int : 4字節 (32位,
原创 muduo之Logger
Logger用來記錄和分析日誌。 Logging.h // Use of this source code is governed by a BSD-style license // that can be found
原创 muduo之Singleton
muduo中的單例模式 Singleton.h // Use of this source code is governed by a BSD-style license // that can be found in