This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int main() | |
| { | |
| // ... | |
| auto employee_less_than = [] (const Employee& lhs, const Employee& rhs) | |
| { | |
| return lhs.get_balance() < rhs.get_balance(); | |
| }; | |
| std::vector<Employee> employees_sorted; | |
| // ... | |
| int total_funds /* = ... */; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Employee | |
| { | |
| public: | |
| int get_salary() const { return m_salary; } | |
| int get_balance() const { return m_balance; } | |
| void pay_salary() { m_balance += m_salary; } | |
| bool operator== (const Employee& rhs) const | |
| { | |
| return m_name == rhs.m_name && |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template <typename StringT, typename CharT, typename MappedT> | |
| class prefix_tree_iterator | |
| { | |
| private: | |
| using key_type = StringT; | |
| using mapped_type = MappedT; | |
| using self = prefix_tree_iterator<key_type, CharT, mapped_type>; | |
| public: | |
| using iterator_category = std::bidirectional_iterator_tag; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Iterators */ | |
| iterator begin(); | |
| const_iterator begin() const; | |
| const_iterator cbegin() const; | |
| iterator end(); | |
| const_iterator end() const; | |
| const_iterator cend() const; | |
| reverse_iterator rbegin(); | |
| const_reverse_iterator rbegin() const; | |
| const_reverse_iterator crbegin() const; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template <typename ContainerT> | |
| ByteArray toByteArray(const ContainerT& container, typename std::enable_if<Generic::is_stl_container<ContainerT>::value>::type* /*= nullptr*/) | |
| { | |
| ByteArray result; | |
| result += toByteArray(static_cast<uint32_t>(container.size())); | |
| for (const auto& item : container) { | |
| result += toByteArray(item); | |
| } | |
| return result; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Selectors */ | |
| const_iterator find(const key_type& key) const; | |
| size_type size() const; | |
| size_type max_size() const; | |
| bool empty() const; | |
| reference at(const key_type& key); | |
| const_reference at(const key_type& key) const; | |
| /* Mutators */ | |
| iterator find(const key_type& key); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public: | |
| /* Constructors, assignment and destructor */ | |
| explicit prefix_tree(const allocator_type& a = allocator_type()); | |
| prefix_tree(const prefix_tree&) = default; | |
| prefix_tree(prefix_tree&&) = default; | |
| prefix_tree(std::initializer_list<value_type> il, const allocator_type& a = allocator_type()); | |
| template <typename FwdIterT> | |
| prefix_tree(FwdIterT first, FwdIterT last, const allocator_type& a = allocator_type()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public: | |
| using key_type = StringT; | |
| using mapped_type = MappedT; | |
| using value_type = std::pair<const key_type, mapped_type>; | |
| using char_type = typename key_type::value_type; | |
| using size_type = std::size_t; | |
| using allocator_type = AllocatorT; | |
| using reference = mapped_type&; | |
| using const_reference = const mapped_type&; | |
| using pointer = typename std::allocator_traits<allocator_type>::pointer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template <typename StringT, | |
| typename MappedT, | |
| typename AllocatorT = std::allocator<MappedT> > | |
| class prefix_tree |