随笔分类 - 数据结构&算法
摘要:在数据结构【二】:简单阻塞队列BlockingQueue的基础上添加权限属性:priority,并控制enqueue时根据priority排序插入.1.定义priority取值范围0~92.dequeue取出priority值最大的节点(最高进先出 largest-in,first-out ).3.若priority相等,则继续遵循FIFO原则注意 :此代码未经生产环境检验,仅供学习参考.PriorityQueue.h#ifndef CUR_PRIORITYQUEUE_H#define CUR_PRIORITYQUEUE_H#include #include struct node{ i...
阅读全文
摘要:在POSIX多线程【一】:简单队列simple queue的基础上使用内部互斥锁和条件变量来控制并发以达到线程安全的目的,其主要用于 [生产者-消费者] 队列.1.BlockingQueue初始化时会确定队列容量(_capacity),如果队列已满(capacity=0),则会阻塞enqueue操作.2.关闭BlockingQueue(调用queue_free)是一个延迟的操作,它会等待所有元素都dequeue,期间,该队列的一切enqueue操作将无效.3.此代码未经生产环境检验,仅供学习参考.BlockingQueue.h#ifndef CUR_BLOCKINGQUEUE_H#define
阅读全文
摘要:简单的FIFO队列实现,非线程安全!1.queue.h :abstract data type queue#ifndef CUR_QUEUE_H#define CUR_QUEUE_H#includestruct node{ int value; struct node * next;};typedef struct queue{ int max,cur; struct node * head, * tail;}queue;extern queue* empty_queue(int _max);extern int queue_free(queue *q);exter...
阅读全文
摘要:我们知道,在编程的世界里,主要就是两个事,用一定的算法去处理一定的数据。算法可以理解为业务逻辑流程,而数据自然一定是按某种结构来存放,这就是数据结构。我们知道,数据结构的修改一定会导致算法的修改,我们也知道,数据结构直接关系到了整个程序的繁简性,高效性。而算法则是关系到数据处理的时间、空间性能,以及日后的扩展和维护。这两个东西是计算机科班出生的人或是需要学习编程的人必需要注意的两件头等大事。下面这个网站,由Software and Systems Division,Information Technology Laboratory创建。http://xlinux.nist.gov/dads/这
阅读全文
摘要:基础Stack栈: 数组实现Stack栈: 链表实现Queues队列: 数组实现Queues队列: 链表实现Lists列表: 数组实现 (java版演示)Lists列表: 链表实现 (java版演示)索引Binary Search Trees二叉检索树AVL Trees (平衡二叉检索树)Red-Black Trees 红黑树 (flash版本演示)Open Hash Tables 开放哈希表(Closed Addressing链地址法)Closed Hash Tables 闭合哈希表 (Open Addressing 开放定址法)Closed Hash Tables, using bucke
阅读全文
摘要:NameLinkDateAddedLanguageDescriptionBinomial Heap(link)7‑24‑2010C++An implementation of abinomial heapdata structure for use as a priority queue.Bounded Priority Queue(link)7‑24‑2010C++An implementation of apriority queuewith a fixed upper limit to its size..Matrix(link)7‑24‑2010C++A collection of c
阅读全文

浙公网安备 33010602011771号