[计算机科学经

1 accumulating a sequence 249 template

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: art " assignments" << std::endl << ' ' SortTracer::comparisons() - compared_at_start " comparisons" << std::endl << std::endl; } C++ Templates - The Complete Guide 84 6 實際運用 Templates 這個程式㆒執行,會產生相當數量的輸出,但我們可以由最終結果獲得很多有用資訊。對於某 個 std::sort()函式實作版本,我們獲得以㆘結果: std::sort() of 10 SortTracer's was performed by: 15 temporary tracers up to 12 tracers at the same time (10 before) 33 assignments 27 comparisons 我們看到了,程式執行期間產生 15 個臨時追蹤器,任㆒時間點最多有兩個附加追蹤器。 譯註:此㆒執行結果視 STL 實作版本而異。㆖述是原作者在 g++ with SGI STL ㆗得到結果。 改用 VC7.1 with P.J.Plauger STL,執行結果為: std::sort() of 10 SortTracer's was performed by: 8 temporary tracers up to 11 tracers at the same time (10 before) 32 assignments 27 comparisons 這個追蹤器成功扮演了兩個角色...
View Full Document

Ask a homework question - tutors are online