Share via


<vector>

定義容器類別樣板 vector 和數種支援的類別樣板。

vector 是以線性順序組織指定類型項目的容器。 它可讓您快速隨機存取任何項目,並動態地加入序列及從序列中移除。 當隨機存取效能很重要時,vector 是慣用的序列容器。 如果不確定要使用哪種容器類型,請選擇向量。

如需類別 vector 的詳細資訊,請參閱 vector 類別。 如需特製化 vector<bool> 的相關資訊,請參閱 vector<bool> 類別

namespace std {
template<class Type, class Allocator>
    class vector;
template<class Allocator>
    class vector<bool>;

template<class Allocator>
    struct hash<vector<bool, Allocator> >;

        // TEMPLATE FUNCTIONS
template<class Type, class Allocator>
    bool operator== (
        const vector< Type, Allocator>& _Left,
        const vector< Type, Allocator>& _Right
    );
template<class Type, class Allocator>
    bool operator!= (
        const vector< Type, Allocator>& _Left,
        const vector< Type, Allocator>& _Right
    );
template<class Type, class Allocator>
    bool operator< (
        const vector< Type, Allocator>& _Left,
        const vector< Type, Allocator>& _Right
    );
template<class Type, class Allocator>
    bool operator> (
        const vector< Type, Allocator>& _Left,
        const vector< Type, Allocator>& _Right
    );
template<class Type, class Allocator>
    bool operator<= (
        const vector< Type, Allocator>& _Left,
        const vector< Type, Allocator>& _Right
    );
template<class Type, class Allocator>
    bool operator>= (
        const vector< Type, Allocator>& _Left,
        const vector< Type, Allocator>& _Right
    );
template<class Type, class Allocator>
    void swap (
        vector< Type, Allocator>& _Left,
        vector< Type, Allocator>& _Right
    );
}  // namespace std

參數

  • 類型
    儲存在向量中之資料類型的樣板參數。

  • 配置器
    儲存之配置器物件的樣板參數,負責記憶體配置和解除配置。 在大多數情況下,您可以忽略這個參數並直接使用預設配置器。

  • _Left
    比較作業中的第一個 (左) 向量

  • _Right
    比較作業中的第二個 (右) 向量。

運算子

operator! =

測試運算子左邊的向量物件是否不等於右邊的向量物件。

運算子 <

測試運算子左邊的向量物件是否小於右邊的向量物件。

運算子 <=

測試運算子左邊的向量物件是否小於或等於右邊的向量物件。

operator==

測試運算子左邊的向量物件是否等於右邊的向量物件。

運算子 >

測試運算子左邊的向量物件是否大於右邊的向量物件。

運算子 >=

測試運算子左邊的向量物件是否大於或等於右邊的向量物件。

類別

vector 類別

序列容器的類別樣板,以線性排列方式排列指定類型的項目,並允許快速隨機存取任何項目。

特製化

vector<bool> 類別

bool 類型項目之樣板類別向量的完整特製化,並提供特製化所使用之基礎類型的配置器。

需求

標頭:<vector>

命名空間: std

請參閱

參考

C++ 標準程式庫中的執行緒安全

標準樣板程式庫

其他資源

<vector> 成員

C++ 標準程式庫標頭檔