原创 linux高性能服務器編程學習筆記八:I/O複用

1、I/O複用使得程序能夠監聽多個文件描述符,網絡程序一般在下列情況使用I/O複用技術    1)客戶端要同時處理多個socket。(非阻塞connect技術)    2)客戶端程序既要處理用戶輸入又要進行網絡連接。(聊天室技術)   

原创 Leetcode: reorder-list

Leetcode: reorder-list Given a singly linked list L: L 0→L 1→…→L n-1→L n, reorder it to: L 0→L n →L 1→L n-1→L 2→L n-

原创 Leetcode: linked-list-cycle-ii

Leetcode: linked-list-cycle-ii Given a linked list, return the node where the cycle begins. If there isno cycle, return

原创 linux高性能服務器編程學習筆記九:信號

1、信號是由系統、用戶或進程發送給目標進程的信息,以通知目標信息某個狀態的改變或系統異常。Linux信號可由如下條件產生: (1)對於前臺進程,可以輸入某些特殊的終端字符來給它發送信號。(Ctrl+C給前臺進程發送中斷信號) (2)諸如越

原创 幾何着色器

幾何着色階段位於頂點和像素着色階段之間。當頂點着色器以頂點作爲輸入數據,幾何着色器是以完整的圖元(這裏指的是三角形)作爲輸入數據。例如,如果我們繪製三角形列表,那麼將在列表中爲每個三角形T執行幾何着色程序。注意,每個三角形的三個頂點都被輸

原创 Leetcode: binary-tree-preorder-traversal(非遞歸版)

Leetcode: binary-tree-preorder-traversal Given a binarytree, return the preorder traversal of itsnodes' values. 思路:運用棧,

原创 Leetcode:Candy

Leetcode: candy There are N children standing in a line. Each child is assigned arating value. You are giving candies t

原创 C#本質論之接口

先描述接口的概念C#並非只能通過繼承使用多態性,也可以通過接口使用。和抽象類不同,接口不包含任何實現(C++並不會特意去區分抽象類和接口,實際上C++的接口就是通過抽象類實現,其並沒有interface和abstract關鍵字)。接口的意

原创 Leetcode:insertion-sort-list

Sort a linked list using insertion sort. 提供兩種思路,遞歸和非遞歸。 遞歸思路: 遞歸的對鏈表進行插入排序,遞歸直到鏈表末尾結束,然後進行插入排序。 舉個例子:4->6->5->7->2->3->

原创 Leetcode: single-number && single-number-ii

Given an array of integers, everyelement appears twice except for one. Find that single one. Note: Your algorithm shou

原创 Leetcode: gas-station

There are N gas stations along a circular route, where the amountof gas at station i isgas[i]. You have a car with an

原创 Leetcode: longest-consecutive-sequence

Given an unsorted array ofintegers, find the length of the longest consecutive elements sequence. For example, Given[1

原创 Leetcode:binary-tree-postorder-traversal

Givena binary tree, return the postorder traversal of its nodes' values. 後續遍歷二叉樹。 遞歸思想:前遍歷左子樹,再遍歷右子樹,最後顯示自身的值。 代碼如下: v

原创 Python Cookbook讀書筆記

1.1每次處理一個字符解決方案:列表化(list)、for循環遍歷、列表推導、map函數thelist = list(thestring) for c in thestring: do_something

原创 Python編程實戰讀書筆記之工廠方法模式(一)

如果子類的某個方法需要根據情況來決定用什麼類去實例化相關對象,那麼可以考慮工廠方法模式。打個比方,假如要繪製一個國際跳棋與國際象棋棋盤,如圖所示:生成國際跳棋棋盤的棋子對象的方法代碼如下:def popul