FBB::LinearMap(3bobcat)

Linear-search based mapping container
(libbobcat-dev_6.04.00)

2005-2023

NAME

FBB::LinearMap - A mapping container using linear searching

SYNOPSIS

#include <bobcat/linearmap>

DESCRIPTION

The class template LinearMap implements a mapping container using a linear searching algorithm. A mapping container using linear searching is less complex than either the sorted std::map or the unsorted std::unordered_map container. For relative small number of elements the linear search algorithm is also faster than the binary search or hashing-based searching algorithms.

LinearMap implements all of the members which are also found in the standard std::map, except for the key_comp and value_comp members. These latter two members are not available as ordering the keys is not an issue with the unordered, linear searching method which is used by LinearMap.

NAMESPACE

FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.

INHERITS (PRIVATELY) FROM

std::vector<Key, Value>

TEMPLATE TYPES

The full template type definition of LinearMap is:

    template < typename Key, typename Value >
        
The Key type must offer bool operator==. Furthermore, Key and Value types must support default and copy constructors and overloaded (copy) assignment operators.

USING SPECIFICATIONS

CONSTRUCTORS

Default, copy and move constructors (and copy and move assignment operators) are available.

OVERLOADED OPERATORS

EXAMPLE

#include <iostream>
#include <string>
#include <iostream>

#include <bobcat/linearmap>

using namespace std;
using namespace FBB;

int main()
{
    typedef LinearMap<string, string> LM;

    // constructors:
    LM lm;
    LM lm2 =
    {
        {"one", "value 1"},
        {"two", "value 2"}
    };
    LM lm3(lm2);

    LM lm4(lm3.begin(), lm3.end());

    // assignment:
    lm = lm2;

    // some members:
    lm["key"] = "value";
    cout << lm["key"] << '\n';
    cout << lm.find("key")->second << '\n';

    for (auto value: lm)
        cout << "For loop: " << value.first << ", " <<
                                                value.second << '\n';

    cerr << "# times 'key' is stored: " << lm.count("key") << "\n"
            "# times 'value is stored: " << lm.count("value") << '\n';

    lm4 = lm2;
    cout << "lm4's size after assignment: " << lm4.size() << '\n';

    lm4.clear();
    cout << "lm4's size after clear: " << lm4.size() << '\n';
};

FILES

bobcat/linearmap - defines the class interface

SEE ALSO

bobcat(7)

BUGS

None Reported.

BOBCAT PROJECT FILES

BOBCAT

Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.

COPYRIGHT

This is free software, distributed under the terms of the GNU General Public License (GPL).

AUTHOR

Frank B. Brokken (f.b.brokken@rug.nl).