c++
jinyyu
这个作者很懒,什么都没留下…
展开
-
分治和自顶向下动态规划算法
Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *. Example 1 I原创 2015-08-03 23:11:47 · 808 阅读 · 0 评论 -
Basic Calculator II
Implement a basic calculator to evaluate a simple expression string. The expression string contains only non-negative integers, +, -, *, / operators and empty spaces . The integer division should原创 2015-07-19 22:55:30 · 408 阅读 · 0 评论 -
Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *原创 2015-07-28 23:25:35 · 343 阅读 · 0 评论 -
二叉树中序遍历(迭代)
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return the next smallest number in the BST. Note: next() and原创 2015-07-11 00:35:19 · 347 阅读 · 0 评论 -
asio测试
测试了一下boost的异步io. 客户端::分出100个线程,每一个都向服务发出connect,连接成功就打印一条消息。 服务器端:主线程调用async_accept,handler函数先调用一个async_accept以接收新的请求。然后就去干自己的事了(sleep几秒) 服务器: #include #include #include using namespace std;原创 2015-03-04 22:04:06 · 507 阅读 · 0 评论 -
基于asio实现pop3的几个指令
//测试 #include #include #include using namespace std; using namespace email; int main() { try{ io_service i; pop3 p(i,"pop.126.com"); p.Set_DebugLevel (true); p原创 2015-04-06 01:40:16 · 397 阅读 · 0 评论 -
优先队列实现
先上测试: #include #include #include #include #include #include"max_heap.h" #include"boost/progress.hpp" using namespace std; fstream output("log.log" , fstream::out); //生成1000个随机数,插入, void test1()原创 2015-04-04 17:40:48 · 466 阅读 · 0 评论 -
用socket(asio)实现了smtp的几个简单的指令
测试主程序 #include #include #include"logging.h" #include"smtplib.h" using namespace std; using namespace boost::asio; using namespace logging; using namespace smtplib; int main() { try{原创 2015-03-29 20:05:46 · 646 阅读 · 0 评论 -
重新写了一个简单的日志类
之前写的了个日志类,感觉写得比较啰嗦,重新写一个比较简单的,功能跟之前差不多. #ifndef LOGGING #define LOGGING #include #include #include #include #include namespace logging { static const long long MAXSIZE = 1024*1024; //最大尺寸 using原创 2015-03-29 01:35:34 · 352 阅读 · 0 评论 -
写了个异步日志
主要实现:简单的异步日志,工作线程只需把日志消息写入缓冲,不必阻塞与耗时的IO操作,由一个背景线程专门负责IO操作。 采用的数据结构,前端为双缓冲区,后端为BlockingQueue,缓冲区的初始化和析构都由背景线程负责,两块缓冲交替使用。 大致的逻辑是:前端使用两块缓冲A和B,A为写缓冲,B为预备缓冲,当写满了A,则交换A和B,并通知背景线程来走B。 背景线程接到前端线程的通知,被唤醒,取原创 2015-08-07 07:02:58 · 1358 阅读 · 0 评论