I “wrote” an inefficient STL subset

Time:2020-1-14

tinySTL

I refer to “STL source code analysis” to “write” an inefficient STL subset. There are more detailed comments in the code, which can be used as auxiliary materials for reading STL source code analysis.

This project is my practice project, so I haven’t provided the test temporarily, so I can’t guarantee it is completely correct. Please forgive me.

As for how to be “inefficient”, I will sort out some of the inefficiencies I have foreseen. Coming soon.

Source code

Github

Completed

  • Space Configurator
  • Ordinary iterator
  • reverse iterator
  • vector
  • list
  • deque
  • stack
  • queue
  • heap
  • priority_queue
  • Rb_tree (implementation from GitHub)
  • set
  • multiset
  • map
  • multimap
  • Hashtable (refer to here for other hash functions)
  • 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
  • algorithm

    • 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 (simple implementation)

    • shared_ptr
    • weak_ptr
    • unique_ptr
    • addressof
    • uninitialized_copy
    • uninitialized_copy_n
    • uninitialized_fill
    • uninitialized_fill_n
  • cstring

    • strcpy
    • strncpy
    • memcpy

TODO

  • Exception guarantee
  • Allocator static member function problem
  • bitset
  • dynamic_bitset
  • string

Sentiment

  • Mr. Hou Jie said:“Before the source code, no secret” After copying the container code, I became more familiar with itSTL。 For choosing different containers to solve different problems, I am more confident to choose a suitable container when I know why.
  • Start to understand the meaning of copy (move) constructor, copy function and usage scenarios.