文章

lec3 Containers

none

Sequence

  • when should I use a stringstream?
    • processing strings
      • simplify “/./a/b/..” to “/a”
    • formatting input/output
      • uppercase, hex, and other string manipulators
    • parsing different types
      • stringToInteger() from previous lectures
  • if you are just concatenating strings, str.append() is faster than using a stringstream!

overview of stl(standard template library)

  • containers
  • adapters
  • iterator
  • functors/lambdas
  • algorithm

  • sequence container

  • std::vector
    • in stl, name braket notation dose not check whether you are out of bounds, it fail sliently, so before use braket, you need to checkout it
    • why stl’s braket notation does not checkout automatically?
      • for performance(without if)?
      • default you write the right code
      • etc…
  • but put a element in the front of vector is very low, so people invented std::deque

  • std::deque
    • a sized array
    • use index to get element slower than vector
  • vector is the type of sequence that should be used by default…deque is the data structure of choice when most insetations and deletions take place at the beginning or the end of the sequence
本文由作者按照 CC BY 4.0 进行授权

热门标签