tinySTL
本人蔘考《STL源碼剖析》“寫”了一個低效的STL 子集。代碼中有比較詳細的註釋,可作爲閱讀《STL源碼剖析》的輔助材料。
本項目爲本人的練習項目,所以暫時未提供測試,不能保證完全正確。請多多包涵。
至於怎麼“低效”了,我後面會整理一些我已經能預見到會低效的實現。敬請期待。
源碼
已完成
- 空間配置器
- 普通迭代器
- 反向迭代器
- vector
- list
- deque
- stack
- queue
- heap
- priority_queue
- rb_tree(實現來自GitHub)
- set
- multiset
- map
- multimap
- hashtable(其他 hash 函數參考here)
- unordered_set
- unordered_map
- unordered_multiset
- unordered_multimap
-
type traits
- integral_constant
- true_type
- false_type
- is_same
- is_integral
- remove_reference
- remove_reference_t
- add_lvalue_reference
- add_lvalue_reference_t
- add_rvalue_reference
- add_rvalue_reference_t
- __type_traits
-
算法
- all_of
- any_of
- none_of
- for_each
- count
- count_if
- mismatch
- find
- find_if
- find_if_not
- find_end
- find_first_of
- adjacent_find
- search
- search_n
- copy
- copy_if
- copy_n
- copy_backward
- move
- move_backward
- remove
- remove_if
- remove_copy
- remove_copy_if
- replace
- replace_if
- replace_copy
- replace_copy_if
- swap
- swap_ranges
- iter_swap
- reverse
- reverse_copy
- rotate
- rotate_copy
- unique
- unique_copy
- is_partitioned
- partition
- partition_copy
- max
- max_element
- min
- min_element
- equal
- lexicographical_compare
- move
-
functional
- hash
- plus
- minus
- multiplies
- divides
- modulus
- negate
- equal_to
- not_equal_to
- greater
- less
- greater_equal
- less_equal
- logical_and
- logical_or
- logical_not
- bit_and
- bit_or
- bit_xor
- identity
- select1st
- select2nd
-
utility
- initializer_list
- forward
- move
- pair
- make_pair
-
numeric
- iota
- accumulate
- inner_product
- adjacent_difference
- partial_sum
-
memory(簡單實現)
- shared_ptr
- weak_ptr
- unique_ptr
- addressof
- uninitialized_copy
- uninitialized_copy_n
- uninitialized_fill
- uninitialized_fill_n
-
cstring
- strcpy
- strncpy
- memcpy
TODO
- 異常保證
- allocator static成員函數問題
- bitset
- dynamic_bitset
- string