- 博客(154)
- 收藏
- 关注
原创 多进程和多线程对比
对比维度多进程多线程总结数据共享、同步数据共享复杂,需要用IPC;数据是分开的,同步简单因为共享进程数据,数据共享简单,但也是因为这个原因导致同步复杂各有优势内存、CPU占用内存多,切换复杂,CPU利用率低占用内存少,切换简单,CPU利用率高线程占优
2014-10-16 19:27:12 570
原创 epoll与select
epoll的优点主要是一下几个方面:1. 监视的描述符数量不受限制,它所支持的FD上限是最大可以打开文件的数目,这个数字一般远大于2048,举个例子,在1GB内存的机器上大约是10万左 右,具体数目可以cat /proc/sys/fs/file-max察看,一般来说这个数目和系统内存关系很大。select的最大缺点就是进程打开的fd是有数量限制的。这对 于连接数量比较大的服务器来说根本不能
2014-10-06 21:14:31 334
转载 session和cookie
二者的定义:当你在浏览网站的时候,WEB 服务器会先送一小小资料放在你的计算机上,Cookie 会帮你在网站上所打的文字或是一些选择,都纪录下来。当下次你再光临同一个网站,WEB 服务器会先看看有没有它上次留下的 Cookie 资料,有的话,就会依据 Cookie里的内容来判断使用者,送出特定的网页内容给你。 Cookie 的使用很普遍,许多有提供个人化服务的网站,都是利用
2014-10-06 14:55:15 376
原创 nginx负载均衡
nginx 的 upstream目前支持 4 种方式的分配 1)、轮询(默认) 每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器down掉,能自动剔除。 2)、weight 指定轮询几率,weight和访问比率成正比,用于后端服务器性能不均的情况。 3)、ip_hash 每个请求按访问ip的hash结果分配,这样每个访客固定访
2014-10-06 14:16:51 306
原创 socket recv和send函数
1.send 函数int send( SOCKET s, const char FAR *buf, int len, int flags ); 不论是客户还是服务器应用程序都用send函数来向TCP连接的另一端发送数据。客户程序一般用send函数向服务器发送请求,而服务器则通常用send函数来向客户程序发送应答。 该函数的第一个参数指定发送端套接
2014-10-05 11:06:01 443
原创 C++智能指针
智能指针(smart pointer)是存储指向动态分配(堆)对象指针的类,用于生存期控制,能够确保自动正确的销毁动态分配的对象,防止内存泄露。它的一种通用实现技术是使用引用计数(reference count)。智能指针类将一个计数器与类指向的对象相关联,引用计数跟踪该类有多少个对象共享同一指针。每次创建类的新对象时,初始化指针并将引用计数置为1;当对象作为另一对象的副本而创建时,拷贝构造函数拷
2014-10-04 09:41:43 340
原创 php如何利用ftp获取文件
// 联接FTP服务器$conn = ftp_connect("10.1.1.240");// 使用username和password登录ftp_login($conn, 'miao', '65272156');//被动模式(PASV)的开关,打开或关闭PASV(1表示开)ftp_pasv($conn, 1);// 获取远端系统类型ftp_systype($conn);
2014-10-03 16:25:44 2266
原创 php如何解析xml
php解析xml主要有以下几种方式:Xml parser, SimpleXML, XMLReader, DOMDocument。我主要使用
2014-10-03 16:19:11 329
转载 大型网站系统架构的演化
前言一个成熟的大型网站(如淘宝、京东等)的系统架构并不是开始设计就具备完整的高性能、高可用、安全等特性,它总是随着用户量的增加,业务功能的扩展逐渐演变完善的,在这个过程中,开发模式、技术架构、设计思想也发生了很大的变化,就连技术人员也从几个人发展到一个部门甚至一条产品线。所以成熟的系统架构是随业务扩展而完善出来的,并不是一蹴而就;不同业务特征的系统,会有各自的侧重点,例如淘宝,要解决海量的
2014-10-03 15:25:57 383
原创 leetcode-Construct Binary Tree from Preorder and Inorder Traversal
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */cla
2014-10-03 13:55:14 331
原创 leetcode-Letter Combinations of a Phone Number
iven a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit str
2014-10-03 13:54:45 342
原创 leetcode-Binary Tree Zigzag Level Order Traversal
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary
2014-10-03 13:54:33 233
原创 leetcode-Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.
2014-10-03 13:54:15 325
原创 leetcode-Combination Sum
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited numb
2014-10-03 13:53:24 298
原创 leetcode-Partition List
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of
2014-10-03 13:52:43 240
原创 leetcode-Triangle
iven a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [6
2014-10-03 13:52:40 296
原创 leetcode-Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum = 22, 5 / \
2014-10-03 13:51:37 394
原创 leetcode-Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine i
2014-10-03 13:51:06 318
原创 leetcode-3Sum Closest
Given an array S 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 have exact
2014-10-03 13:50:53 304
原创 leetcode-Unique Binary Search Trees II
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1 3
2014-10-03 13:50:38 270
原创 leetcode-Subsets II
Given a collection of integers that might contain duplicates, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain dupli
2014-10-03 13:50:33 281
原创 leetcode-Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.
2014-10-03 13:49:59 236
原创 leetcode-Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST./** * Definition for singly-linked list. * struct ListNode { * int val; * Lis
2014-10-03 13:48:05 298
原创 leetcode-Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n satisfy t
2014-09-28 21:15:22 304
原创 leetcode-Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [ ["aa","
2014-09-28 21:10:34 296
原创 leetcode-Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".
2014-09-28 21:01:39 304
原创 leetcode-N-Queens
he n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle.
2014-09-28 20:33:51 251
原创 leetcode-Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node's key.Th
2014-09-28 20:31:41 251
原创 leetcode-Pow(x, n)
class Solution {public: double powPositive(double x, int n){ if(n == 0) return 1; if(n == 1) return x; double tmp; if(n%2 == 0){ tmp = powPos
2014-09-28 20:28:00 293
原创 leetcode-Gas Station
There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to
2014-09-28 19:30:46 312
原创 leetcode-Next Permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible
2014-09-28 19:29:05 354
原创 leetcode-Permutations II
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1].
2014-09-28 19:22:54 382
原创 leetcode-Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is
2014-09-28 19:22:15 293
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人