U E D R , A S I H C RSS

EffectiveSTL/Vector And String

  • �� ���� ���� vector, string�� ���� 팁 ��������. 큰1�� ������� ������ ����(할�� ��..)�� ���� ������.



1. Item13. Prefer vector and string to dynamically allocated arrays.

1.1. new/delete ���� ������

  • new 해���� delete 해������ ����.
  • delete [] delete �� �� 함. ���� ���� ���� �� ������ ��.
  • �� delete한 ������ �� delete하�� "������ ����... " �� ���� �� ��.

1.2. vector/string ���� �� ����

  • ������ �������� �� 한��.(��)
  • ������ ����������.(���� ��)
  • ���� ����하 ���� ���� ����한��.
  • char* ��������.

1.3. ������ ������

  • reference count�� �� ������.. ��하�� �.. ���� �� ��?--a AfterCheck
  • ������ 환������ ���� �������� ����해�� ���� ������������.. ���� ���� ������..--;



2. Item14. Use reserve to avoid unnecessary reallocations.

2.1. vector/string�� ��������할�� �� ���� ��

  • ������ ��������.(������ ���� ����.)
  • ���� ��테���� ���� ������ 할�������� ������.
  • ���� ��테������ ���� ������ ����한��.
  • ���� ��테���� ��������한��.

2.2. ������ ���� ��테��� 크���� ��������

  • size() - ��� ��테���� ���� ���� ������ ��.(���� ��)
  • capacity() - ��� 할���� ���� �������� �� ����할�� ���� ���� ��
  • resize(n) - n�� �� ���� ������ ��할
    • n�� ��� size()���� ���� - ����� size() - n ��� ����.
    • n�� ��� size()���� 크�� - ����� n - size() ����� �� ����.
    • n�� ��� capacity()���� 크�� - ������ ��할��.
  • reserve() - �� ��테���� capacity ���� n�� ���� 할.
    • vector������ ��� capacity���� n�� ������? - ����.
    • string���� ? ������.(--;)

2.3. �� ���� ������ reserve ������ ����하��.

  • reserve ����하�� ��할, ������, 포����, ���� �� �� ����화 ��킬�� ����.
  • reserve�� ���� 크�� �� ���� ������ trim() ����. �� ������.



3. Item15. Be aware of variations in string implementations.




4. Item16. Know how to pass vector and string data to legacy APIS




5. Item17. Use 'the swap trick' to trim excess capacity.




6. Item18. Avoid using vector<bool>.

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:10
Processing time 0.0150 sec