惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

大猫的无限游戏
大猫的无限游戏
K
Kaspersky official blog
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog
aimingoo的专栏
aimingoo的专栏
M
MIT News - Artificial intelligence
小众软件
小众软件
云风的 BLOG
云风的 BLOG
腾讯CDC
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Hugging Face - Blog
Hugging Face - Blog
S
SegmentFault 最新的问题
Stack Overflow Blog
Stack Overflow Blog
量子位
S
Secure Thoughts
G
GRAHAM CLULEY
C
CXSECURITY Database RSS Feed - CXSecurity.com
人人都是产品经理
人人都是产品经理
雷峰网
雷峰网
T
Threat Research - Cisco Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cisco Talos Blog
Cisco Talos Blog
G
Google Developers Blog
爱范儿
爱范儿
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
有赞技术团队
有赞技术团队
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Martin Fowler
Martin Fowler
The GitHub Blog
The GitHub Blog
Google DeepMind News
Google DeepMind News
C
Cisco Blogs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
博客园 - 聂微东
宝玉的分享
宝玉的分享
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
Netflix TechBlog - Medium
Forbes - Security
Forbes - Security
Engineering at Meta
Engineering at Meta
S
Security Affairs
Help Net Security
Help Net Security
博客园 - 三生石上(FineUI控件)
AWS News Blog
AWS News Blog
博客园 - 叶小钗
Recent Commits to openclaw:main
Recent Commits to openclaw:main
V2EX - 技术
V2EX - 技术
Hacker News: Ask HN
Hacker News: Ask HN
Project Zero
Project Zero
H
Heimdal Security Blog
W
WeLiveSecurity
C
Check Point Blog

Posts on Changkun's Blog

Why High-Output Systems Are Often the First to Stop Growing Dark Forest Theory: A Formal Derivation Agents (or Humans) in Goal-Directed and Goalless Environments: On Pipelines, Priors, and the Rhythm Between Exploration and Exploitation At the Boundary of Self-Reference: From Stable Structures in Artificial Intelligence to the Self as a Recursive Model in an Open Dissipative System 2023 Reading List 2022 Reading List 2021 Reading List Are PSS/USS and RSS Actually the Same Thing? Performance Differences from Page Faults vs. Prefetching 2020 Year-End Review Migration with Zero Downtime 2020 Reading List The All in Go Stack Pointers Might Not Be Ideal for Parameters Eliminating A Source of Measurement Errors in Benchmarks Setup Wordpress in 10 Minutes 我为什么不再写博客了? 2019 年终总结 2018-2019 读书清单 Ten years of blogging Rethinking the Reflections on Communications and Trusts 2018 年终总结 Go source code study is open source Go source study: unsafe Pattern Go source study: sync.Pool Go runtime programming A Million WebSocket and Go Designing Asynchronous RESTful APIs 分布式杂谈01:CAP 理论的误解 Issues of Human-Bot Interaction 压缩法与深度网络的泛化性 Go in 1 Hour UMSLT04: The Past and Present of SGD UMSLT03: A Gentle Start of Learning Theory UMSLT02: A Breif History of Neural Networks UMSLT01: A Breif History of Regularization 不笑不足以为道 论文笔记:Generalization in Deep Learning 2017 年终总结 2017 读书清单 深度学习的泛化理论简介 删除 GitHub 上已经提交的敏感信息 硕士生涯的第一年就这样告一段落了 人肉计算(10): 系统参与激励 人肉计算(9): 陷阱的解法 别聊,一聊你就暴露 人肉计算(8): 人肉计算与数据科学中的陷阱 人肉计算(7): 社会行为分析 Hexo + GitHub + Travis CI + VPS 自动部署 人肉计算(6): 预测市场 人肉计算(5): 信用风险评级模型 读书与回报 瞎扯: 对现代企业理论与当下IT企业的商业模式和信息产业链的规律性的思考 人肉计算(4): 输入数据聚合与PageRank 又一次打整了一下博客 人肉计算(3): 输入数据聚合与链路预测 人肉计算(2): 意图博弈 GWAPs 人肉计算(1): 众包与群众智慧 对后辈同学在计算机专业上的答疑与解惑 在德国的医疗及住院体验 这可能不是一个技术博客了 实验楼楼赛第3期-Python-题解 迅速更换了 DISQUS Electron 深度实践总结 良好的编码体验的三个方面 2016 年终总结 2016 读书清单 最近在着手写的文章 微信小程序文档极致总结 谈谈过去三个月在实验楼的实习经历 Built a Desktop Client for My Blog Guacamole 源码分析与 VNC 中 RFB 协议的坑 《高速上手 C++11/14》正式发布 Docker 极速入门教程02 - 镜像与容器管理 Docker 极速入门教程01 - 基本概念和操作 阶段性沉默 ELK+Redis 最佳实践 终于全面启用了 HTTPS 苹果开源了LZFSE无损压缩 Hash 碰撞的一种思路 记一次完整的 Kaldi-TIMIT 示例运行 Kaldi 上的 TIMIT 例子 Kaldi 安装与部署 从科研写作谈起 Swift API 设计指南 有趣的人类 所以其实论文并没有什么鬼用 Githug 通关记录及指南 小结一下这学期的收获 2015 读书清单 2015 年终总结 负能量爆表 转眼就快两个月了 博客迁移记录 大三总结 这个世界,终究不会是我们的。 Linux 内核分析 之六:Linux 内核创建进程的过程 小说「泽缘」 Linux 内核分析 之五:system_call中断处理过程的简要分析 大创项目的标题真是每年都在考验同学们的想象力啊
模版链队实现
Changkun Ou · 2013-10-06 · via Posts on Changkun's Blog

模版链队实现

Published at发布于:   |   PV/UV: /   |   Reading阅读: 3 min

队列作为允许在前段删除和后端插入得线性表,和栈类似,是一种操作受限制得线性。进行插入操作的端称之为队尾,进行删除操作的端称之为队头。队列中没有元素时,称之为空队列。尽管操作受到限制,但是仍然具有使用价值,如可以利用队列结构编写消息队列处理消息,利用队列结构编写内存池时可以将可用内存区块加入一个队列中等待使用,等等。 这次实现的模版链队本质上仍是链表,这次的队列没有首节点,队列中全部元素均为队列中的成员。代码中注释了一个迭代器,是测试代码时候写的。 p.s.可以考虑重载[]来实现队列中的数据访问。。当然这是后话了。。

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
//
//  Queue.h
//  链表
//
//  Created by 欧 长坤 on 13-10-5.
//  Copyright (c) 2013年 欧 长坤. All rights reserved.
//

#ifndef ______Queue__
#define ______Queue__

#include <iostream>

template <class T> class Queue;
//template <class T> class QueueIterator;

template <class T>
class QueueNode{
    friend class Queue<T>;
    //friend class QueueIterator<T>;
private:
    T data;
    QueueNode<T> *next;
};

template <class T>
class Queue{
    //friend class QueueIterator<T>;
private:
    QueueNode<T> *First;
    QueueNode<T> *Last;
    size_t Size;
public:
    Queue();
    ~Queue();
    void enqueue(T &value); // 入队
    bool dequeue(); // 出队
    T front();
    T back();
    bool isEmpty();
    size_t size();
    void clear();
    // 可以考虑重载[]
};

// 迭代器用于测试enqueue是否成功而写

// 链队迭代器
// 使用方法:
// int *x;
// QueueIterator<int> inter;
// x = inter.initialize(XXX); // XXX是队列
// while (inter) {
//      cout << *x << ' ';
//      x = inter.next();
// }
/*
template <class T>
class QueueIterator
{
private:

    QueueNode<T> *location;

public:

    T* initialize(const Queue<T>& queue)
    {
        location = queue.Last;
        if (location)
            return &location->data;
        return 0;
    }
    T* next()
    {
        if (!location)
            return &location->data;
        location = location->next;
        if (location) {
            return &location->data;
        }
        return 0;
    }

};
*/

template <class T>
Queue<T>::Queue()
{
    First = Last = new QueueNode<T>;
    if (NULL == First) {
        throw &quot;Out Of Memory!&quot;;
    } else {
        First->next = NULL;
    }
    Size = 0;
}

template <class T>
Queue<T>::~Queue()
{
    delete First;
    First = Last = NULL;
    Size = 0;
}

template <class T>
void Queue<T>::enqueue(T &value)
{
    QueueNode<T> *newQueueNode = new QueueNode<T>;
    if (NULL == newQueueNode) {
        throw &quot;Out Of Memory!&quot;;
    }
    newQueueNode->next = Last;
    newQueueNode->data = value;
    Last = newQueueNode;
    if (isEmpty()) {
        First = Last;
        First->next = NULL;
    }
    Size++;
}

template <class T>
bool Queue<T>::dequeue()
{
    if (isEmpty())
        return false;
    QueueNode<T> *p, *q;
    p = First;
    q = Last;
    while (q->next != p) {
        q = q->next;
    }
    First = q;
    First->next = NULL;
    delete p;
    Size--;
    return true;
}

template <class T>
T Queue<T>::front()
{
    return First->data;
}

template <class T>
T Queue<T>::back()
{
    return Last->data;
}

template <class T>
bool Queue<T>::isEmpty()
{
    if (Size == 0)
        return true;
    else
        return false;
}

template <class T>
size_t Queue<T>::size()
{
    return Size;
}

template <class T>
void Queue<T>::clear()
{
    QueueNode<T> *q = Last->next;
    while (NULL == q)
    {
        delete Last;
        Last = q;
        q = Last->next;
    }
    Last = First = NULL;
    Size = 0;
}

#endif /* defined(______Queue__) */