freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

cprime筆記(參考版)

2024-08-25 16:03本頁面
  

【正文】 // 如果兩容器的位序列。 bool operator ==(const bitsetNamp。 // 返回對應(yīng)的 unsigned long 值;如果溢出,則拋出overflow_error string to_string() const。 set(size_t pos, bool val = true)。 set()。 reset(size_t pos)。 reset()。 // 將位置 pos 處的位取反;如果 pos = size(),那么將拋出異常out_of_range。 bitsetNamp。 // 將容器內(nèi)所有位全部取反 bitsetN operator~()。 // 返回被置為 1 的位的個(gè)數(shù) bitsetNamp。 //容器內(nèi)的位個(gè)數(shù) N size_t size() const。 reference operator(size_type pos)。 reference at(size_type pos)。 // 測試位置 pos 處的位是否為 val(默認(rèn)測試是否為 1) // 如果 pos = size(),那么將拋出異常 out_of_range bool at(size_type pos) const。 // 如果容器內(nèi)沒有位被置為 1,則返回 true;否則返回 false。 // 如果容器內(nèi)有任意位被置為 1,則返回 true;否則返回 false。 // bs5 有 8 位,并且只使用 test 串的前八個(gè)字符 11111000來初始化, // 所以 07 位為: 0001 1111(注意與源串反向) bitset8 bs6(test, 4, 3)。 // bs4 有 8 位,并全部初始化為 1 string test(111110000011)。 // bs2 有 16 位,并全部初始化為 1 bitset32 bs3(0xFFFF)。(這點(diǎn)符合我們看待字符串形式的位串的方式:左邊是高位,右邊是低位) 舉例: bitset16 bs1。如果指定的字符序列中字符個(gè)數(shù)比 bitset 對象位數(shù)要多,則只使用前 面的字符。如果指定的字符序列 [pos, pos + n)中有非 0、 1字符,那么將拋出 invalid_argument 異常。 用 string 對象中從 pos 下標(biāo)開始的 n 個(gè)字符來初始化 bitset 對象(這些字符必須是 0 或者 1)。 如果 bitset 對象的長度小于 val的位數(shù),那么 val中多余的高位被丟棄; 如果 bitset 對象的長度大于 val的位數(shù),那么 bitset 對象的高位將被置為 0 explicit bitset(const stringamp。 初始化所有位都為 0 bitset(unsigned long val)。 bitset 對象元素的位置編號(hào)從 0 到 N 1,對應(yīng)著位串從低位到高位。 bitset 也是類模板,其模板參數(shù) N 必須是常量表達(dá)式(能夠在編譯時(shí)計(jì)算出其值),表示 bitset 類對象的長度(位的個(gè)數(shù))。 比較 (operator == or operator !=) 所有迭代器都支持迭代器之間的比較: operator ==:如果兩個(gè)迭代器指向同一元 素,那么返回 true;否則返回 false。 訪問容器元素 (operator*) 假如迭代器 it 指向容器的一個(gè)元素,那么解引用 *it 就是該元素的值(注意,不能對 end()解引用)。其中, begin 返回的迭代器指向第一個(gè)元素, end 返回的迭代器指向最后一個(gè)元素的下一個(gè)位置(實(shí)際上是一個(gè)不存在的元素),所以迭代序列為 [begin(), end())。一般提供兩種類型: iterator 和 const_iterator。迭代器類型提供了比下標(biāo)操作更通用的方法: 所有標(biāo)準(zhǔn)容器類都定義了相應(yīng)的迭代器類型,而只有少數(shù)的容器支持下標(biāo)操作。 迭代器 迭代器 (iterator)是用來遍歷容器內(nèi)所有元素的數(shù)據(jù)類型。特別需要 說明的是,第二個(gè)循環(huán)在條件判斷中使用了 size()函數(shù),而不是在循環(huán)之前先保存在變量中再使用。 return 0。 assert(() () == ())。 ++i) coutv[i]endl。 for(vectorstring::size_type i = 0。 assert(*it == hello, world)。 ++i) coutv[i]endl。 for(vectorstring::size_type i = 0。 (() + 3, 4, hello, world)。 it ()。 cout Before operationendl。 vectorstring v2((), ())。 應(yīng)用示例 include iostream include cassert include vector using namespace std。注意 it2 it1 返回值為 difference_type( signed 類型)。因?yàn)?,operator!=(lhs, rhs) 就是 !(lhs == rhs), operator=(lhs, rhs) 就是 !(rhs lhs),operator(lhs, rhs) 就是 (rhs lhs), operator=( lhs, rhs) 就是 !(lhs, rhs)。 對于 operator、 operator=、 operator、 operator=,采用字典排序策略比較。 vector 對象的比較(非成員函數(shù)) 針對 vector 對象的比較有六個(gè)比較運(yùn)算符: operator==、 operator!=、 operator、 operator=、operator、 operator=。 const_reverse_iterator rend() const。 const_reverse_iterator rbegin() const。 const_iterator end() const。 const_iterator begin() const。 x = T())。 void clear() const。 // 刪除指定元素,并返回刪除元素后一個(gè)元素的位置(如果無元素,返回 end()) iterator erase(iterator first, iterator last)。 // 注意迭代器可能不再有效(可能重新分配空間) void insert(iterator it, const_iterator first, const_iterator last)。 // 在插入點(diǎn)元素之前插入元素(或者說在插入點(diǎn)插入元素) void insert(iterator it, size_type n, const Tamp。 // 彈出容器中最后一個(gè)元素(容器必須非空) // 注:下面的插入和刪除操作將發(fā)生元素的移動(dòng)(為了保持連續(xù)存儲(chǔ)的性質(zhì)),所以之前的迭代器可能失效 iterator insert(iterator it, const Tamp。 x)。 // 返回下標(biāo)為 pos 的元素的引用;如果下標(biāo)不正確,則拋出異常 out_of_range const_reference at(size_type pos) const。 const_reference operator[](size_type pos) const。 reference operator[](size_type pos)。 reference back()。 reference front()。 // 確保 capacity() = n void resize(size_type n, T x = T())。 // 返回容器中元素個(gè)數(shù) size_type capacity() const。 // 如果為容器為空,返回 true;否則返回 false size_type max_size() const。 // 創(chuàng)建有 5 個(gè)值為 “hello”的 string 類對象的容器 vectorstring v4((), ())。 // 創(chuàng)建空容器,其對象類型為 string 類 vectorstring v2(10)。如果沒有指定存儲(chǔ)對象的初始值,那么對于內(nèi)置類型將用 0 初始 化,對于類類型將調(diào)用其默認(rèn)構(gòu)造函數(shù)進(jìn)行初始化(如果有其它構(gòu)造函數(shù)而沒有默認(rèn)構(gòu)造函數(shù),那么此時(shí)必須提供元素初始值才能放入容器中)。 vector(const_iterator first, const_iterator last)。 // 創(chuàng)建有 n 個(gè)元素的 vector 對象 vector(const vectoramp。 // 默認(rèn)構(gòu)造函數(shù), vector 對象為空 explicit vector(size_type n, const Tamp。 與對 string 類對象的介紹一樣,仍然使用簡化原型(主要是拋棄了分配器模板參數(shù),使用默認(rèn)的)。 如果文中有錯(cuò)誤或遺漏之處,敬請指出,謝謝! vector容器類型 vector 容器是一個(gè)模板類,可以存放任何類型的對象(但必須是同一類對象)。只適合于有了一定的 C++基礎(chǔ)的讀者(至少學(xué)完一本 C++教程)。如 果要得到一行,一是可以設(shè)置輸入流的格式(詳見關(guān)于輸入輸出流的內(nèi)容),另一個(gè)更簡單的方法是使用上面提到的 getline 函數(shù)。 另一個(gè)建議就是:如果同一 string 類對象的修改操作比較頻繁,那么可以先調(diào)用 reserve()確保足夠的空間,以避免后面的修改過程中重新分配內(nèi)存,提高效率。這樣,當(dāng)字符串只是作為值參數(shù)或在其他情形下使用時(shí),這種方法能夠節(jié)省時(shí)間和空間。還有一個(gè)很重要的原因,那就是 string 類可以實(shí)現(xiàn)寫時(shí)拷貝(這由編譯器決定是否予與實(shí)現(xiàn)),這樣如果程序中有較多的字符串拷貝操作的話,那么可以大大提高程序的效率,并減少存儲(chǔ)空間的使用。 return 0。 assert((LNo) == string::npos)。) == 3)。 assert((39。r39。 assert((wsecond) == 0)。 iwstring wsecond = LSTRING。 coutFirst: first, Second: secondendl。 assert((Ing) == 3)。I39。) == 2)。 assert((39。 assert(first == second)。 int main() { istring first = string。 s) { return os()。 operator (std::wostream amp。 typedef std::basic_stringwchar_t, iwchar_traits iwstring。 } return NULL。 n 0。 } return 0。 ++str1, ++str2) { if (towupper(*str1) towupper(*str2)) return 1。 for (。 } static int pare(const wchar_t* str1, const wchar_t* str2, size_t n) { if (str1 == NULL) return 1。 struct iwchar_traits: std::char_traits wchar_t { static bool eq(wchar_t c1, wchar_t c2) { return towupper(c1) == towupper(c2)。 s) { return os()。 operator (std::ostreamamp。 typedef std::basic_stringchar, ichar_trai
點(diǎn)擊復(fù)制文檔內(nèi)容
畢業(yè)設(shè)計(jì)相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1