Giter Site home page Giter Site logo

\mainpage

wilderfield

The wilderfield library is a collection of header only libraries I've developed over time for various purposes.

wilderfield::PriorityMap

The PriorityMap class is designed to manage a set of elements, each with a priority,
allowing for efficient retrieval, updating, and tracking of elements based on their priority.

It is designed to provide constant time access to the element with the highest priority,
as well as constant time priority increment and decrement.

Setting priority for a given element directly is O(n).

The underlying implementation is a doubly linked list backed by a hashmap.

The source code for this project is available on GitHub: wilderfield/wilderfield

usage

Here is a basic example of how to use the PriorityMap class:

#include "wilderfield/PriorityMap.hpp"
#include <iostream>

int main() {

  // Define a PriorityMap instance
  wilderfield::PriorityMap<int, int> pmap;

  // Increment priority of key 7
  ++pmap[7];

  // Retrieve and check the top element
  auto [key, value] = pmap.Top();
  std::cout << "Top element key: " << key << " with priority: " << value << std::endl;

  return 0;
}

example application

Below is an example application illustrating topological sort with Khan's algorithm and a priority map:

#include "wilderfield/PriorityMap.hpp"
#include <vector>
#include <cassert>

std::vector<int> TopSort(std::vector<std::vector<int>>& graph) {
 
   std::vector<int> result;
 
   // Construct priority map with lower values as highest priority
   wilderfield::PriorityMap<int, int, std::less<int>> pmap;
 
   // Initialize pmap to have all nodes with indegree 0
   for (int u = 0; u < graph.size(); u++) {
     pmap[u] = 0;
   }
 
   // Calculate indegrees for each node
   for (int u = 0; u < graph.size(); u++) {
     for (auto v : graph[u]) {
         ++pmap[v];
     }
   }
 
   // Iterate over nodes by smallest indegree
   while (!pmap.Empty()) {
     auto [u, min_val] = pmap.Top(); pmap.Pop();
     assert(min_val == 0); // If not the graph has a cycle
     result.push_back(u);
     for (auto v : graph[u]) { // Decrease indegrees after removing node u
       --pmap[v];
     }
   }
 
   return result;
}

build, test, benchmark, install

Typical CMake build, tune commands to your platform/generator

cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake β€”-build build
build/tests/priority_map_test -s
build/benchmark/run_benchmarking
cmake --install build

documentation

For more information and advanced usage, refer to the respective class and method documentation.

The documentation for this project is available on GitHub: [wilderfield/wilderfield documentation/(https://wilderfield.github.io/wilderfield)

Bryan Lozano's Projects

cocoapi icon cocoapi

COCO API - Dataset @ http://cocodataset.org/

ggml icon ggml

Tensor library for machine learning

keras icon keras

Deep Learning library for Python. Convnets, recurrent neural networks, and more. Runs on Theano or TensorFlow.

onnxruntime icon onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator

pcimem icon pcimem

Simple program to read & write to a pci device from userspace

robin_stocks icon robin_stocks

This is a library to use with Robinhood Financial App. It currently supports trading crypto-currencies, options, and stocks. In addition, it can be used to get real time ticker information, assess the performance of your portfolio, and can also get tax documents, total dividends paid, and more. More info at

scripts icon scripts

Utility scripts for working with Xilinx SoC devices

taskflow icon taskflow

A General-purpose Parallel and Heterogeneous Task Programming System

tt-metal icon tt-metal

:metal: TT-NN operator library, and TT-Metalium low level kernel programming model.

vitis-ai icon vitis-ai

Vitis AI is Xilinx’s development stack for AI inference on Xilinx hardware platforms, including both edge devices and Alveo cards.

webcam-client icon webcam-client

Javascript magic to capture webcam frames from your PC, and send to the cloud

xrt icon xrt

Xilinx Run Time for FPGA

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.