2019-05-09 12:36:53 +07:00
2019-05-09 11:17:25 +07:00
2019-05-09 11:17:25 +07:00
2019-05-09 02:43:47 +07:00
2019-05-04 09:05:58 +07:00
2019-05-04 09:05:58 +07:00
2019-05-04 09:05:58 +07:00
2019-05-07 03:25:15 +07:00
2019-05-04 09:05:58 +07:00
2019-05-09 12:36:53 +07:00

flat.hpp

travis appveyor codecov language license paypal

Installation

flat.hpp is a header-only library. All you need to do is copy the headers files from headers directory into your project and include them:

#include "flat_hpp/flat_set.hpp"
using namespace flat_hpp;

int main() {
    flat_set<int> s;
    s.insert(42);
    return 0;
}

Also, you can add the root repository directory to your cmake project:

add_subdirectory(external/flat.hpp)
target_link_libraries(your_project_target flat.hpp)

API

Flat Set

template < typename Key
         , typename Compare = std::less<Key>
         , typename Container = std::vector<Key> >
class flat_set;

Member types

Member type Definition
key_type Key
value_type Key
size_type Container::size_type
difference_type Container::difference_type
key_compare Compare
value_compare Compare
container_type Container
reference Container::reference
const_reference Container::const_reference
pointer Container::pointer
const_pointer Container::const_pointer
iterator Container::const_iterator
const_iterator Container::const_iterator
reverse_iterator Container::const_reverse_iterator
const_reverse_iterator Container::const_reverse_iterator

Member functions

flat_set();

explicit flat_set(const Compare& c);

template < typename Allocator >
explicit flat_set(const Allocator& a);

template < typename Allocator >
flat_set(const Compare& c, const Allocator& a);

template < typename InputIter >
flat_set(InputIter first, InputIter last);

template < typename InputIter >
flat_set(InputIter first, InputIter last, const Compare& c);

template < typename InputIter, typename Allocator >
flat_set(InputIter first, InputIter last, const Allocator& a);

template < typename InputIter, typename Allocator >
flat_set(InputIter first, InputIter last, const Compare& c, const Allocator& a);

flat_set(std::initializer_list<value_type> ilist);

flat_set(std::initializer_list<value_type> ilist, const Compare& c);

template < typename Allocator >
flat_set(std::initializer_list<value_type> ilist, const Allocator& a);

template < typename Allocator >
flat_set(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a);

template < typename Allocator >
flat_set(flat_set&& other, const Allocator& a);

template < typename Allocator >
flat_set(const flat_set& other, const Allocator& a);

flat_set(flat_set&& other);
flat_set(const flat_set& other);

flat_set& operator=(flat_set&& other);
flat_set& operator=(const flat_set& other);

flat_set& operator=(std::initializer_list<value_type> ilist);

Iterators

iterator begin() noexcept;
const_iterator begin() const noexcept;
const_iterator cbegin() const noexcept;

iterator end() noexcept;
const_iterator end() const noexcept;
const_iterator cend() const noexcept;

reverse_iterator rbegin() noexcept;
const_reverse_iterator rbegin() const noexcept;
const_reverse_iterator crbegin() const noexcept;

reverse_iterator rend() noexcept;
const_reverse_iterator rend() const noexcept;
const_reverse_iterator crend() const noexcept;

Capacity

bool empty() const noexcept;
size_type size() const noexcept;
size_type max_size() const noexcept;
size_type capacity() const noexcept;
void reserve(size_type ncapacity);
void shrink_to_fit();

Modifiers

std::pair<iterator, bool> insert(value_type&& value);
std::pair<iterator, bool> insert(const value_type& value);

iterator insert(const_iterator hint, value_type&& value);
iterator insert(const_iterator hint, const value_type& value);

template < typename InputIter >
void insert(InputIter first, InputIter last);
void insert(std::initializer_list<value_type> ilist);

template < typename... Args >
std::pair<iterator, bool> emplace(Args&&... args);
template < typename... Args >
iterator emplace_hint(const_iterator hint, Args&&... args);

void clear() noexcept;
iterator erase(const_iterator iter);
iterator erase(const_iterator first, const_iterator last);
size_type erase(const key_type& key);

void swap(flat_set& other);

Lookup

size_type count(const key_type& key) const;

iterator find(const key_type& key);
const_iterator find(const key_type& key) const;

std::pair<iterator, iterator> equal_range(const key_type& key);
std::pair<const_iterator, const_iterator> equal_range(const key_type& key) const;

iterator lower_bound(const key_type& key);
const_iterator lower_bound(const key_type& key) const;

iterator upper_bound(const key_type& key);
const_iterator upper_bound(const key_type& key) const;

Observers

key_compare key_comp() const;
value_compare value_comp() const;

Non-member functions

template < typename Key
         , typename Compare
         , typename Container >
void swap(
    flat_set<Key, Compare, Container>& l,
    flat_set<Key, Compare, Container>& r);

template < typename Key
         , typename Compare
         , typename Container >
bool operator==(
    const flat_set<Key, Compare, Container>& l,
    const flat_set<Key, Compare, Container>& r);

template < typename Key
         , typename Compare
         , typename Container >
bool operator!=(
    const flat_set<Key, Compare, Container>& l,
    const flat_set<Key, Compare, Container>& r);

template < typename Key
         , typename Compare
         , typename Container >
bool operator<(
    const flat_set<Key, Compare, Container>& l,
    const flat_set<Key, Compare, Container>& r);

template < typename Key
         , typename Compare
         , typename Container >
bool operator>(
    const flat_set<Key, Compare, Container>& l,
    const flat_set<Key, Compare, Container>& r);

template < typename Key
         , typename Compare
         , typename Container >
bool operator<=(
    const flat_set<Key, Compare, Container>& l,
    const flat_set<Key, Compare, Container>& r);

template < typename Key
         , typename Compare
         , typename Container >
bool operator>=(
    const flat_set<Key, Compare, Container>& l,
    const flat_set<Key, Compare, Container>& r);

Flat Map

template < typename Key
         , typename Value
         , typename Compare = std::less<Key>
         , typename Container = std::vector<std::pair<Key, Value>> >
class flat_map;

Member types

Member type Definition
key_type Key
mapped_type Value
value_type Container::value_type
size_type Container::size_type
difference_type Container::difference_type
key_compare Compare
container_type Container
reference Container::reference
const_reference Container::const_reference
pointer Container::pointer
const_pointer Container::const_pointer
iterator Container::iterator
const_iterator Container::const_iterator
reverse_iterator Container::reverse_iterator
const_reverse_iterator Container::const_reverse_iterator

Member classes

class value_compare;

Member functions

flat_map();

explicit flat_map(const Compare& c);

template < typename Allocator >
explicit flat_map(const Allocator& a);

template < typename Allocator >
flat_map(const Compare& c, const Allocator& a);

template < typename InputIter >
flat_map(InputIter first, InputIter last);

template < typename InputIter >
flat_map(InputIter first, InputIter last, const Compare& c);

template < typename InputIter, typename Allocator >
flat_map(InputIter first, InputIter last, const Allocator& a);

template < typename InputIter , typename Allocator >
flat_map(InputIter first, InputIter last, const Compare& c, const Allocator& a);

flat_map(std::initializer_list<value_type> ilist);

flat_map(std::initializer_list<value_type> ilist, const Compare& c);

template < typename Allocator >
flat_map(std::initializer_list<value_type> ilist, const Allocator& a);

template < typename Allocator >
flat_map(std::initializer_list<value_type> ilist, const Compare& c, const Allocator& a);

template < typename Allocator >
flat_map(flat_map&& other, const Allocator& a);

template < typename Allocator >
flat_map(const flat_map& other, const Allocator& a);

flat_map(flat_map&& other);
flat_map(const flat_map& other);

flat_map& operator=(flat_map&& other);
flat_map& operator=(const flat_map& other);

flat_map& operator=(std::initializer_list<value_type> ilist);

Iterators

iterator begin() noexcept;
const_iterator begin() const noexcept;
const_iterator cbegin() const noexcept;

iterator end() noexcept;
const_iterator end() const noexcept;
const_iterator cend() const noexcept;

reverse_iterator rbegin() noexcept;
const_reverse_iterator rbegin() const noexcept;
const_reverse_iterator crbegin() const noexcept;

reverse_iterator rend() noexcept;
const_reverse_iterator rend() const noexcept;
const_reverse_iterator crend() const noexcept;

Capacity

bool empty() const noexcept;
size_type size() const noexcept;
size_type max_size() const noexcept;
size_type capacity() const noexcept;
void reserve(size_type ncapacity);
void shrink_to_fit();

Element access

mapped_type& operator[](key_type&& key);
mapped_type& operator[](const key_type& key);

mapped_type& at(const key_type& key);
const mapped_type& at(const key_type& key) const;

Modifiers

std::pair<iterator, bool> insert(value_type&& value);
std::pair<iterator, bool> insert(const value_type& value);

iterator insert(const_iterator hint, value_type&& value);
iterator insert(const_iterator hint, const value_type& value);

template < typename InputIter >
void insert(InputIter first, InputIter last);
void insert(std::initializer_list<value_type> ilist);

template < typename... Args >
std::pair<iterator, bool> emplace(Args&&... args);
template < typename... Args >
iterator emplace_hint(const_iterator hint, Args&&... args);

void clear() noexcept;
iterator erase(const_iterator iter);
iterator erase(const_iterator first, const_iterator last);
size_type erase(const key_type& key);

void swap(flat_map& other)

Lookup

size_type count(const key_type& key) const;

iterator find(const key_type& key);
const_iterator find(const key_type& key) const;

std::pair<iterator, iterator> equal_range(const key_type& key);
std::pair<const_iterator, const_iterator> equal_range(const key_type& key) const;

iterator lower_bound(const key_type& key);
const_iterator lower_bound(const key_type& key) const;

iterator upper_bound(const key_type& key);
const_iterator upper_bound(const key_type& key) const;

Observers

key_compare key_comp() const;
value_compare value_comp() const;

Non-member functions

template < typename Key
         , typename Value
         , typename Compare
         , typename Container >
void swap(
    flat_map<Key, Value, Compare, Container>& l,
    flat_map<Key, Value, Compare, Container>& r);

template < typename Key
         , typename Value
         , typename Compare
         , typename Container >
bool operator==(
    const flat_map<Key, Value, Compare, Container>& l,
    const flat_map<Key, Value, Compare, Container>& r);

template < typename Key
         , typename Value
         , typename Compare
         , typename Container >
bool operator!=(
    const flat_map<Key, Value, Compare, Container>& l,
    const flat_map<Key, Value, Compare, Container>& r);

template < typename Key
         , typename Value
         , typename Compare
         , typename Container >
bool operator<(
    const flat_map<Key, Value, Compare, Container>& l,
    const flat_map<Key, Value, Compare, Container>& r);

template < typename Key
         , typename Value
         , typename Compare
         , typename Container >
bool operator>(
    const flat_map<Key, Value, Compare, Container>& l,
    const flat_map<Key, Value, Compare, Container>& r);

template < typename Key
         , typename Value
         , typename Compare
         , typename Container >
bool operator<=(
    const flat_map<Key, Value, Compare, Container>& l,
    const flat_map<Key, Value, Compare, Container>& r);

template < typename Key
         , typename Value
         , typename Compare
         , typename Container >
bool operator>=(
    const flat_map<Key, Value, Compare, Container>& l,
    const flat_map<Key, Value, Compare, Container>& r);

Flat Multiset

coming soon!

Flat Multimap

coming soon!

License (MIT)

Description
Library of flat vector-like based associative containers
Readme 456 KiB
Languages
C++ 97.4%
CMake 2.6%