U E D R , A S I H C RSS

EffectiveSTL/Programming WithSTL


1. Item43. Prefer algorithm calls to hand-written loops.


2. Item44. Prefer member functions to algorithms with the same names.

2.1. „œก 

  •  œชฉ ทธŒ€กœ.. ฐ™€ ด„˜ •Œณ ฆฌฆ˜„ “ฐŠ” Œ€‹ —, ทธ ปจํ…Œด„ˆ ฐฒด˜ ฐ™€ ด„˜ ฉ”†Œ“œ “ฐŠ”ฒŒ ‚ซ‹ค.
  • ดœ Š”, ” ํšจœจ ดธฐ •Œฌธ—.
  • ˜ ‹คฅธ ดœ Š”, equivalnce™€ equality˜ ฐจด—„œ ˜คŠ” „ณต —ฌ€ž˜Š”ฐ.. ด •ํ„Š” •„ง •ˆดค‹ค.

2.2. ˜ˆ œ

  •  €ฆ‰‹œ €ํ‚ฌˆ˜ žˆฒŒ ํ•˜Š” ˜ˆ œ ณดดฒ ‹ค.

~cpp 
set<int> s;            // s—Š” ›†Œ€ งŒฐœ “ค–ดžˆ‹ค. ด ค‘—„œ 727ดŠ” ›†Œ ฐพณ  ‹ถ‹ค.
typedef set<int>::iterator SIIT;
...

// ฉ”†Œ“œ ํ˜ธถœ „ 
SIIT i = s.find(727);

...

// •Œณ ฆฌฆ˜ ํ˜ธถœ „ 
SIIT j = find(s.begin(), s.end(), 727)

2.3. „ช…

  • set˜ findฉ”†Œ“œŠ” กœทธ‹œ„‚ด— ˆ˜ํ–‰œ‹ค. ํ•˜€งŒ find •Œณ ฆฌฆ˜€ „ ํ˜•‹œ„‚ด— ˆ˜ํ–‰œ‹ค. ฆ‰
    • findฉ”†Œ“œ˜ average caseŠ” 20, worst caseŠ” 40.
    • find•Œณ ฆฌฆ˜˜ average caseŠ” 5‹ญงŒ, worst caseŠ” งŒ.
    • ด ฒฐ ณดฉด ‹—ฐํžˆ  € œ„˜ฒƒ„ €ํ‚คธฐ   ฒƒด‹ค.



3. Item45. Distinguish among count, find, binary_search, lower_bound, upper_bound, and equal_range.


4. Item46. Consider function objects instead of functions as algorithm parameters.


5. Item47. Avoid producing write-only code.


6. Item48. Always #include the proper headers.


7. Item49. Learn to decipher STL_related compiler diagnostics.


8. Item50. Familiarize yourself with STL-releated websites.

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