STL-stack模拟实现
1.BST 二叉搜索树 BinarySearchTree 思路分析与实现 C++2.手搓平衡搜索树-AVL树 平衡修正 图文详解 (万字长文)3.详细分析平衡树-红黑树平衡修正 图文详解 (万字长文)4.STL 改造红黑树 模拟封装set和map5.STL map、set、multi_map、multi_set 基本概念与用法6.STL-string模拟实现7.STL-vector模拟实现8.STL-priority_queue模拟实现9.STL-queue模拟实现
10.STL-stack模拟实现
11.STL-list模拟实现12.STL-RBT_map,set模拟实现13.STL-RBTree模拟实现14.STL-unordered_hashtable模拟实现15.STL-unordered_map,unordered_set模拟实现16.哈希表17.AVL树18.红黑树19.平衡搜索树20.STL-bitset模拟实现#pragma once #include<assert.h> #include<list> #include<vector> #include<deque> #include<iostream> using std::cout; using std::endl; using std::cin; namespace test { //template<class T, class Containers=std::vector<T>> template<class T, class Containers=std::deque<T>> class stack { private: Containers con; public: void push(const T& val) { con.push_back(val);//尾插尾删 } void pop() { con.pop_back(); } const T& top() { return con.back(); } bool empty() { return con.empty(); } size_t size() { return con.size(); } }; //测试用例 //stack的使用 void test_stack1() { stack<int> st1; st1.push(1); st1.push(2); st1.push(3); while (!st1.empty()) { cout << st1.top() << endl; st1.pop(); } } void test_stack2() { stack<int,std::list<int>> st; st.push(1); st.push(2); st.push(3); while (!st.empty()) { cout << st.top()<<endl; st.pop(); } } }
本文来自博客园,作者:HJfjfK,原文链接:https://www.cnblogs.com/DSCL-ing/p/18038574
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了