miscellaneous : <μ¬λ¬Ό λ±μ΄> ννμμμ (κ²μΌλ‘ μ΄λ£¨μ΄μ§), κ°κ°μ§ μ‘λ€ν, μ‘λμ¬λμ
νΉλ³ν μμΉν κ³³μ΄ μλ μ 보λ€μ νμ΄μ§. μμ¬μ λΆλ¦¬λ©λλ€.
----
μνλ κ° μμ νκΈ° ¶
- μ΄λ€ 컨ν
μ΄λκ° intκ°λ€μ λ΄κ³ μλ€κ³ νμ. κ±°κΈ°μ 1982 λΌλ μ«μλ₯Ό λͺ½λ
μ§μμ£Όκ³ μΆλ€λ©΄?
- Contiguous-memory container μΌλ
- Contiguous-memory container μΌλ
~cpp c.erase( remove(c.begin(), c.end(), 1982), c.end() ); // μ΄κ±΄ λ΄λΆμ μΌλ‘ μ΄λ»κ² λμκ°λ κ±ΈκΉ. μ°Ύμλ΄μΌκ² κ΅°.
- listμΌλ - erase μ¨λ λμ§λ§ removeκ° λ ν¨μ¨μ μ΄λ€.
~cpp c.remove(1982);
- Associative container μΌλ - removeμ°λ©΄ λ리λλ€.(μμΌλκΉ--;) λ μ λ€λ¦ μκ³ λ¦¬μ¦ removeλ μμ μλλ€. 컨ν
μ΄λκ° λ§κ°μ§μλ μλ€.
~cpp c.erase(1982);
νμΌ μ½μ΄ μ€κΈ° ¶
~cpp // ints.dat μμ μ μλ€μ μ½μ΄μ listμ μ μ₯ν΄μ€ ifstream dataFile("ints.dat"); ifstream_iterator<int> dataBegin(dataFile); ifstream_iterator<int> dataEnd; list<int> data(dataBegin, dataEnd); // μλ°μμΌλ‘ μ¨μ£Όμ.
μ£Όμμ¬ν ¶
- 컨ν
μ΄λλ₯Ό μ무거λ μ°λ©΄ μλλ€. κ°μ₯ μ΅μ νλ μλ£κ΅¬μ‘°λ₯Ό μκ°ν΄μ μ¨μΌνλ€.
- vector<Object*> μ΄λ°μμΌλ‘ λμ μμ±νλ κ°μ²΄μ λ νΌλ°μ€λ₯Ό μν ν¬μΈν°λ₯Ό 컨ν
μ΄λμ λ£μλλ μΆν ν¬μΈν°κ° κ°λ¦¬ν€λ κ°μ²΄λ₯Ό μ§μ delete ν΄μ€μΌ νλ€.
STL