Skip to content

TiredAJ/CircularInt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CircularInt

Basically, it's a circular int datatype. For a CInt of 5 with a max of 6 and min of two, you can cycle through those values with the incrementer operator (++):

5->6->2->3->4->5->6->2... onwards

Usage

(taken from wiki)

This library uses .NET 7.0, you might need this.

With the library installed and the using Circular; in place, you can start using CInts.

To start, you can initialise a CInt:

Just the value

//value
CInt Val = new CInt(5);

Just the boundaries

//maximum, minimum
CInt Val = new CInt(10, 0);

or all three

//value, maximum, minimum
CInt Val = new CInt(5, 10, 0);

To use it in the place of an int (such as an index for an array), you can cast it to an int and it should be usable

string[] Names =
    {
        "Erin",
        "Charles",
        "Lexi",
        "Sunny",
        "Cara",
        "Bianca"
    };

CInt i = new CInt(0, (Names.Count() -1), 0);

while (true)
{
    Console.WriteLine(Names[(int)i]);

    i++;
    Thread.Sleep(1500);
}

Hopefully that explains the basics of CInts