Git Product home page Git Product logo

mycontainers's Introduction

MyContainers

Welcome to MyContainers, a collection of C++ implementations for fundamental data structures in STL. This repository includes my personal implementations of Vector, Binary Tree, Singly Linked List, Hash Map, Queue, and Graph. Below you can find brief overview of the containers, for more detailed documentation please refeer to the docs folder.

Table of Contents

  • Vector
  • BinaryTree
  • ForwardList
  • HashMap
  • Queue
  • Graph
  • Vector
  • Stack

Vector

The Vector class in this repository is an implementation of a dynamic array that can resize itself as needed. It provides functionalities similar to those of std::vector in the C++ Standard Library.

Usage example:

#include <iostream>
#include <Vector.h>

int main()
{
    my::Vec<int> vec{};

    vec.Push(10);
    vec.Push(5);
    vec.Push(1);

    for (const auto& e : vec)
    {
        std::cout << element << " ";
        // Or just cout the vector itself
        // std::cout << vec << std::endl;
    }

    return 0;
}

BinaryTree

The BinaryTree class implements a binary tree data structure with basic traversal and manipulation methods.

Usage example:

#include <BinaryTree.h>

int main()
{
    my::BinaryTree<int> tree{};

    tree.Insert(5);
    tree.Insert(15);
    tree.Insert(115);

    auto vec = tree.InOrder();

    return 0;
}

ForwardList

The ForwardList class is an implementation of a singly linked list with methods for insertion, deletion, and traversal.

Usage example:

#include <iostream>
#include <ForwardList.h>

int main()
{
    my::ForwardList<int> list{};

    list.PushFront(10);
    list.PushFront(13);
    list.PushFront(12);

    std::cout << list << std::endl;

    return 0;
}

HashMap

The HashMap class provides a simple hash map implementation with basic key-value pair operations.

Usage example:

#include <iostream>
#include <HashMap.h>

int main()
{
    my::HashMap<std::string, int> map{};

    map.Insert("one", 1);
    map.Insert("two", 2);
    map.Insert("four??", 4);

    std::cout << "Value for key 'two': " << myMap.At("two") << std::endl;

    return 0;
}

Queue

The Queue class represents a basic queue data structure with enqueue and dequeue operations.

Usage example:

#include <iostream>
#include <Queue.h>

int main()
{
    my::Queue<int> queue{};

    queue.Push(1);
    queue.Push(2);
    queue.Push(3);

    while (!queue.Empty()) {
        std::cout << myQueue.Pop() << " ";
    }

    return 0;
}

Graph

The Graph class is an implementation of an undirected graph with methods for adding vertices and edges, as well as basic graph traversal algorithms.

Usage example:

#include <Graph.h>

int main()
{
    my::Graph<int> graph{};

    graph.AddVertex(1);
    graph.AddVertex(2);
    graph.AddEdge(1, 2);

    auto shortest_path = graph.GetShortestPath(1, 2);

    return 0;
}

Feel free to explore each container’s header and source files for a detailed understanding of the implementations and their methods. If you have any questions or suggestions, please don’t hesitate to reach out. Happy coding!

mycontainers's People

Contributors

neddx avatar

Watchers

 avatar

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.