FBB:...rMap(3bobcat)
π FBB:...rMap β the 3bobcat era π
okay bestie, buckle up, we're doing a whole manual page and it's literally about a little mapping container called FBB::LinearMap β¨
πΈ NAME πΈ
FBB::LinearMap β a mapping container that uses linear searching. yes. it just... walks the line, one element at a time, and find you π
β¨ SYNOPSIS β¨
#include <bobcat/linearmap>
π¦ DESCRIPTION π¦
The class template LinearMap implements a mapping container using a linear searching algorithm. ngl, a mapping container that linear-searches is less complex than either the sorted std::map or the unsorted std::unordered_map container. and lowkey? for a relatively small number of elements, linear search is also faster than binary search or hashing-based searching algorithms. it's giving "small but mighty" π₯
LinearMap implements all of the members which are also found in the standard std::map, except for the key_comp and value_comp members. those two are simply not available, because ordering the keys is not an issue with the unordered, linear searching method that LinearMap uses. no ordering, no drama, no comparator π
π 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>
yes, bestie, it's inheriting privately β remember that, it matters later π
π TEMPLATE TYPES π
The full template type definition of LinearMap is:
template < typename Key, typename Value >
The Key type must offer bool operator==. Furthermore, the Key and Value types must support default and copy constructors and overloaded (copy) assignment operators. no cap, it's a whole vibe check on your types π
π USING SPECIFICATIONS π
using value_type = std::pair<Key, Value>;iteratorβ an iterator to aLinearMapobject's elements;const_iteratorβ aconst_iteratorto aLinearMapobject's elements;reverse_iteratorβ areverse_iteratorto aLinearMapobject's elements;const_reverse_iteratorβ aconst_reverse_iteratorto aLinearMapobject's elements.
π CONSTRUCTORS π
LinearMap(Iterator begin, Iterator end)β the constructor is initialized using the iterator range[begin, end), whereIteratoris any iterator type pointing tovalue_typeobjects. If identical keysKare used then only the first occurrence of thevalue_typeobject using keyKis inserted.LinearMap(std:initializer_list<value_type> initial)β the constructor is initialized with the values stored in thestd::initializer_listofvalue_typeobjects. If identical keysKare used then only the first occurrence of thevalue_typeobject using keyKis inserted.
Default, copy and move constructors (and copy and move assignment operators) are available. so many options, so slay π
π OVERLOADED OPERATORS π
Value &operator[](Key const &key)β a reference to theValueassociated withkeyis returned. Ifkeywas not available prior to the call of the index operator, avalue_map(key, Value())object is inserted. (yes, the index operator inserts things. it's the main character of side effects π)
π MEMBER FUNCTIONS π
Note that the members of std::vector are not automatically available, as LinearMap is privately inherited from std::vector. that private inheritance is doing its little gatekeeping thing, exactly as promised π
LinearMap offers the following member functions:
Value &at(int idx)β returns a reference to theLinearMap'sValuethat is associated withkey. If the key is not stored in theLinearMapthen anstd::out_of_rangeexception is thrown. π¨iterator begin()β returns an iterator pointing to theLinearMap's first element.size_t capacity()β returns the number of elements that can be stored in theLinearMapbefore its capacity is enlarged.const_iterator cbegin() constβ returns aconst_iteratorpointing to theLinearMap's first element.const_iterator cend() constβ returns aconst_iteratorpointing beyond theLinearMap's last element.void clear()β erases all elements from theLinearMap.size_t count(key)β returns1if the provided key is available in theLinearMap, otherwise0is returned.const_reverse_iterator crbegin() constβ returns aconst_reverse_iteratorpointing to aLinearMapobject's last element.const_reverse_iterator crend() constβ returns aconst_reverse_iteratorpointing before aLinearMapobject's first element.std::pair<iterator, bool> emplace(Args &&...args)β avalue_typeobject is constructed fromemplace's arguments. Astd::pairis returned containing an iterator pointing to the object using that key. If theLinearMapalready contains an object having the providedKeyvalue then the returnedstd::pair'sboolvalue isfalse. If the provided key was not found, then the newly constructed object is inserted into theLinearMap, and the returnedstd::pair'sboolvalue istrue.bool empty()β returnstrueif theLinearMapcontains no elements.iterator end()β returns an iterator pointing beyond theLinearMap's last element.std::pair<iterator, iterator> equal_range(key)β returns a pair of iterators, being respectively the return values of the member functionslower_boundandupper_bound.bool erase(Key const &key)β erases the element having the given key from theLinearMap.Trueis returned if the value was removed,falseif theLinearMapdid not contain an element using the given key.void erase(iterator pos)β erases the element at iterator positionpos.void erase(iterator begin, iterator end)β erases all elements indicated by the iterator range[first, beyond).iterator find(Key const &key)β returns an iterator to the element having the given key. If the element isn't available,endis returned.const_iterator find(Key const &key) constβ returns aconst_iteratorto the element having the given key. If the element isn't available,endis returned.allocator_type get_allocator() constβ returns a copy of the allocator object used by theLinearMapobject.std::pair<iterator, bool> insert(value_type const &keyValue)β tries to inserts a newvalue_typeobject into theLinearMap, returning astd::pair<iterator, bool>. If the returnedti(bool)field istrue,keyValuewas inserted into theLinearMap. The valuefalseindicates that the specified key was already available, andkeyvaluewas not inserted into theLinearMap. In both cases the iterator field points to the data element having the specified key.iterator insert(iterator pos, value_type const &keyValue)β tries to insertkeyValueinto theLinearMap.Posis ignored, and an iterator to the element havingkeyValue's key value is returned. If the specified key was already present,keyValueis not inserted into theLinearMap. (yes bestie,posgets ghosted π)void insert(Iterator begin, Iterator end)β tries to insert thevalue_typeelements pointed at by the iterator range[begin, end)objects into theLinearMap.Iteratoris any iterator type pointing tovalue_typeobjects. Already existingvalue_typeelements having keys equal to the keys of the elements pointed at by the iterator range are not replaced.iterator lower_bound(Key const &key)β returns an iterator pointing to the keyvalue element having the specified key. If no such element exists,endis returned.const_iterator lower_bound(Key const &key) constβ returns aconst_iteratorpointing to the keyvalue element having the specified key. If no such element exists,endis returned.size_t max_size() constβ returns the maximum number of elements thisLinearMapmay contain.reverse_iterator rbegin()β returns areverse_iteratorpointing to theLinearMapobject's last element.const_reverse_iterator rbegin() constβ returns aconst_reverse_iteratorpointing to theLinearMapobject's last element.reverse_iterator rend()β returns areverse_iteratorpointing before theLinearMapobject's first element.const_reverse_iterator rbegin() constβ returns aconst_reverse_iteratorpointing before theLinearMapobject's first element.size_t size() constβ returns the number of elements in theLinearMap.void swap(LinearMap &other)β swaps twoLinearMaps using identicalKeyandValuetypes.iterator upper_bound(Key const &key)β returns an iterator pointing to the keyvalue element having the specified key. If no such element exists,endis returned.const_iterator upper_bound(Key const &key) constβ returns aconst_iteratorpointing to the keyvalue element having the specified key. If no such element exists,endis returned.
β EXAMPLE β
here's the whole example, verbatim, no notes, just vibes:
#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 π₯
π BUGS π
None Reported. iconic behaviour, honestly π
πΈ BOBCAT PROJECT FILES πΈ
https://fbb-git.gitlab.io/bobcat/: gitlab project page;
Debian Bobcat project files:
libbobcat6: debian package containing the shared library, changelog and copyright note;libbobcat-dev: debian package containing the static library, headers, manual pages, and developer info;
π 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).
and that's the whole page bestie π this manual came to you from libbobcat-dev_6.15.01, dated 2005-2026, living under the name FBB:...rMap(3bobcat) β go forth and linear search, you ate π
β¨
π¦ where this page comes from
- ubuntu stonking: libbobcat-dev 6.15.01-1 Β· GPL-3.0-or-later WITH OpenSSL exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms