STL學習
1.sort(a,a+n)
排序函式
https://blog.csdn.net/w_linux/article/details/76222112
#include<iostream> #include<algorithm> using namespace std; bool Ascending(int i, int j) { return i < j; } bool Descending(int i, int j) { return i > j; } int main() { int a[10] = { 1,5,2,3,4,5,8,9,6,5 }; sort(a, a + 10); for (int i = 0; i < 10; i++) { cout << a[i] << " "; } sort(a, a + 10, Descending); for (int i = 0; i < 10; i++) { cout << a[i] << " "; } return 0; }
2.vector<int>
不定長陣列、向量
https://blog.csdn.net/fanyun_01/article/details/56842637
相關推薦
C++ STL學習 queue
pop out 第一個 code 兩個 push stl queue 註意 本文修改自http://www.cnblogs.com/hdk1993/p/5809180.html 1、使用queue需要聲明頭文件#include <queue> 2、queu
STL學習筆記— —無序容器(Unordered Container)
ring 最大 布局 size fad oca rgs template max 簡單介紹 在頭文件<unordered_set>和<unordered_map> 中定義 namespace std { templa
vector--C++ STL 學習
我們 contain gin 創建 vector排序 參考 多種方式 一個 cpp vector對應的數據結構為數組,而且是動態數組,也就是說我們不必關心該數組事先定義的容量是多少,它的大小會動態增長。與數組類似的是,我們可以在末尾進行元素的添加和刪除,也可以進行元素值的隨
STL學習第一章 了解STL
靜態綁定 消息 rst 位置 body and 本質 概念 com 知識內容: 1.STL介紹 2.C++基礎知識復習 3.C++中的模板簡單介紹 4.STL組成部分 一、STL介紹 1.什麽是STL? 學過C++的應該都聽說過STL,那麽什麽是STL呢?STL是S
STL學習
1.sort(a,a+n) 排序函式 https://blog.csdn.net/w_linux/article/details/76222112 #include<iostream> #include<algorithm> using namespace std
STL學習筆記之佇列queue
<queue> 只能訪問queue<T>容器介面卡的第一個和最後一個元素。只能在容器的末尾新增新元素,只能從頭部移除元素。FIFO(先進先出) 1.初始化 需要標頭檔案<queue> queue<int>que;
C++|STL學習筆記-對STL中關聯容器map的進一步認識
關聯容器map key + value 的值 關聯容器 = 有序容器(紅黑樹) + 無序容器(散列表) + hash_map 有序容器中: map的鍵值是不允許重複的 multimap的鍵值是允許重複的 set是一個集合,鍵值=實值,就是隻包含一個值,既是鍵值也是實值,不允許重複 mul
C++|STL學習筆記-map的基本操作(插入,刪除,遍歷,大到小輸出)【仿大佬寫法】
首先的程式碼是插入,刪除,遍歷 執行截圖如下: 原始碼如下: #include <map> #include <iostream> #include <algorithm> using namespace std; typedef pair
STL學習筆記-模板知識
基礎知識 泛化 template<typename T> class Test {}; 特化 template<> Test<int> {}; 偏特化 個數偏特化 template<class T1, clas
STL學習筆記
容器的結構 序列式容器 array 連續的儲存空間 且大小固定 vector 連續的儲存空間 起始位置固定 動態向後擴容 每次增長的大小為2倍增長 動態增長的過程中 需要重新找到空間 需要轉移元素 deque 雙向 分段連續空間 每次新增時擴充一
STL學習_vector_1
#include <iostream> #include <vector> using namespace std; void vector_int_printf(vector<int> v) //列印存入int型別的
STL學習筆記(1)空間配置器 allocator
1 簡述 STL其他元件都是存放在空間配置器配置的空間中,此處空間可以是記憶體,也可以是磁碟或其他輔助儲存介質。 allocator負責記憶體的分配和釋放,以及負責物件的構造和析構,兩個操作時分開的。 每個容器都已經制定了預設的空間配置器
C++ STL學習之 空間配置器(allocator)
標籤(空格分隔): C++ STL 眾所周知,一般情況下,一個程式包括資料結構和相應的演算法,而資料結構作為儲存資料的組織形式,與記憶體空間有著密切的聯絡. 在C++ STL中,空間配置器便是用來實現記憶體空間(一般是記憶體,也可以是硬碟等空間)分配的工具,他與容器聯絡緊密,每一種容器的空間分配都是通過空
(未完成)STL學習筆記(3)序列式容器 (Sequence Containers)
1. vector vector與陣列array十分相似,但array是靜態空間,而vector是動態空間,可以通過內部機制自行擴充空間,具有很好的靈活性。 其實現的關鍵在於對大小的控制和重新配置時的資料移動效率。 vector的型別定義如下: templat
C++STL學習——stack與queue容器
stack容器 簡介 stack是一種堆疊容器,是一種"先進後出"的容器。 stack是簡單地裝飾deque容器而成為另外的一種容器 標頭檔案#include<stack> stack物件的預設構造 stack採用模板類實現, stack
C++STL學習——List容器
List容器 List簡介 list是一個雙向連結串列容器,可高效地進行插入刪除元素。 list不可以隨機存取元素,所以不支援at.(pos)函式與[]操作符。It++(ok) it+5(err) 標頭檔案#include<list> lis
c++STL學習——deque
雙端佇列(deque) Deque簡介 deque是“double-ended queue”的縮寫,和vector一樣都是STL的容器,deque是雙端陣列,而vector是單端的。 deque在介面上和vector非常相似,在許多操作的地方可以直接替換。 deq
C++STL學習——Set集合
簡單介紹 集合(Set)是一種包含已排序物件的關聯容器,其中所包含的元素是唯一的,集合中的元素按一定的順序排列。元素插入過程是按排序規則插入,所以不能指定插入位置。 set採用紅黑樹變體的資料結構實現,紅黑樹屬於平衡二叉樹。在插入操作和刪除操作上比vector快。 s
C++|STL學習筆記-map的屬性(大小以及是否存在)
目錄 1.size()的用法 map的property map屬性 1.沒有容量; 2.得到元素的個數size() 這裡給出呼叫他size()的例子,原始碼如下: /*****
stl學習————離散化
離散化指 資料和數字值無關而和它們大小有關的時候,且空間浪費嚴重的時候,我們可以保留它們的大小關係,壓縮到一定範圍內節省空間的做法。 比如1 2 3 5 8這個序列可壓縮成1 2 3 4 5。 假定待離散化的序列為a[n],sub_a[n]是a[n]的一個