zu1-pvp

๐Ÿš€ StableIndexVector - Simple Vector Storage with Stable IDs

Download StableIndexVector

๐Ÿ“‹ What is StableIndexVector?

StableIndexVector (SIV) is a C++ library designed to make it easy to manage collections of items in your programs. It allows you to keep track of your objects with stable IDs, meaning these IDs stay the same even when you add or remove items. This feature makes it easier to manage your data without worrying about changes affecting your access to each object.

๐ŸŒŸ Features

๐Ÿš€ Getting Started

Follow these steps to download, set up, and use StableIndexVector in your project.

Step 1: Download the Library

To get started, visit the StableIndexVector releases page. Here you will find the latest version available for download.

Download StableIndexVector

Step 2: Install the Library

Once youโ€™ve downloaded the necessary files, you need to copy index_vector.hpp into your project folder.

Step 3: Include the Library in Your Project

Open your C++ code, and include the header file like this:

#include "index_vector.hpp"

Step 4: Begin Using StableIndexVector

You can now start using StableIndexVector in your project. Hereโ€™s a simple example to help you understand how to work with it.

#include "index_vector.hpp"

struct Entity {
    int x, y;
    std::string name;
};

int main() {
    siv::Vector<Entity> entities;
    
    // Add objects - each returns a stable ID
    siv::ID player = entities.emplace_back(0, 0, "Player");
    siv::ID enemy = entities.emplace_back(10, 5, "Enemy");
    
    // Access via ID
    Entity p = entities[player];
    Entity e = entities[enemy];

    return 0;
}

๐Ÿ’ก Download & Install

To download StableIndexVector, visit the following link:

Download StableIndexVector

Once again, simply copy index_vector.hpp to your project and include it in your code.

๐Ÿ”ง Example Usage

Here is a more detailed example that shows how you can manage a list of entities using StableIndexVector.

#include "index_vector.hpp"
#include <iostream>

struct Entity {
    int x, y;
    std::string name;
};

int main() {
    siv::Vector<Entity> entities;

    // Adding entities
    siv::ID player = entities.emplace_back(0, 0, "Player");
    siv::ID enemy = entities.emplace_back(10, 5, "Enemy");

    // Displaying properties
    std::cout << "Player Position: (" << entities[player].x << ", " << entities[player].y << ")\n";
    std::cout << "Enemy Position: (" << entities[enemy].x << ", " << entities[enemy].y << ")\n";

    // Removing an entity
    entities.erase(player); // Player is erased

    // Accessing player after erasure
    if (!entities.is_alive(player)) {
        std::cout << "Player has been erased.\n";
    }

    return 0;
}

โ“ Frequently Asked Questions

Q: Do I need to install anything special to use StableIndexVector?

A: No special installation is needed. Just copy the header file into your project, and youโ€™re ready to go.

Q: Can I use StableIndexVector with any C++ application?

A: Yes, you can integrate StableIndexVector into any C++ project that allows header files.

Q: Will I need to write a lot of code to use it?

A: No, using StableIndexVector is straightforward with just a few lines of code.

๐Ÿ› ๏ธ System Requirements

๐Ÿ“ž Support

If you encounter any issues or have questions, please visit the repositoryโ€™s issues page for assistance. The community is here to help you!

By following these instructions, you can easily download and use StableIndexVector. Enjoy managing your collections with stable and reliable ID systems!