Skip to content

Simple C++ library with useful map functions

License

Notifications You must be signed in to change notification settings

Bucephalus-Studios/stevensMapLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stevensMapLib

A single-header C++ library for expanding std::map and std::unordered_map functionality

Requirements

  • C++20 or later (uses std::string::starts_with())
  • No external dependencies!

Install

Simply copy stevensMapLib.hpp into your project and include it:

#include "stevensMapLib.hpp"

Or use the Beldum Package Manager: https://github.com/Nord-Tech-Systems-LLC/beldum_package_manager

mkdir new_project
cd new_project
beldum init
beldum install stevensMapLib

Building Tests

cd tests
mkdir build && cd build
cmake ..
cmake --build .
ctest

Building Benchmarks

cd benchmarks
mkdir build && cd build
cmake ..
cmake --build .
./maplib_benchmarks

Usage

src/main.cpp

#include "stevensMapLib.hpp"

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

int main()
{
    // Define a map of string keys and double values
    std::map<std::string, double> prices = {
        {"apple", 1.0},
        {"banana", 0.5},
        {"cherry", 2.0}
    };

    // Factor to multiply each price by
    long double factor = 1.1; // For example, a 10% price increase

    // Call the function to multiply each value in the map
    prices = stevensMapLib::multiplyWithValues(prices, factor);

    // Output the updated map
    for (const auto& [key, value] : prices) {
        std::cout << key << ": " << value << std::endl;
    }

    return 0;
}

About

Simple C++ library with useful map functions

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Contributors 3

  •  
  •  
  •