sunnuntai 24. lokakuuta 2010

Programming: The Ranger class

I felt the need for a c++ class which would enable me to do the following:
- Define a finite range of numbers from 0 to N
- Exclude ranges from this range so that the remaining ranges would be accessible as a list
- Reset the range back to full range

Thus came forth the Ranger class.

Files for the project:
- interface header: http://koti.kapsi.fi/~isoa/files/src/ranger/ksym_ranger.h
- implementation: http://koti.kapsi.fi/~isoa/files/src/ranger/ksym_ranger.cpp
- interactive test program: http://koti.kapsi.fi/~isoa/files/src/ranger/ksym_ranger_test.cpp

License is http://evvk.com/evvktvh.html so feel free to stuff this project up your ass.

You can compile the test program with a standards compliant c++ compiler. An example compilation with GNU compiler is as follows:
- c++ -I path_to_ksym_ranger.h ksym_ranger.cpp ksym_ranger_test.cpp

To get an idea what this piece of shit does, check out this example test run (user input in cursive):

$ a
0 -> 100
20 30

0 -> 19
31 -> 100
40 50

0 -> 19
31 -> 39
51 -> 100
60 70

0 -> 19
31 -> 39
51 -> 59
71 -> 100
15 80

0 -> 14
81 -> 100

Ei kommentteja:

Lähetä kommentti