BoolArray 1.1

December 29th, 2010

I’ve just optimized the BoolArray class, and repaired some of the bugs.

Download: boolean.cpp boolean.h

Optimization log:

100,000,000 times

Reading:
1.705 s -> 4th optimization (remove extra variable use)
2.008 s -> 3rd optimization (replace all calculations)
2.485 s -> 2nd optimization (replace calculations by constants)
4.370 s -> 1st optimization (replace multiplication (by 2) by shifting left)
4.990 s -> without optimization

0.675 s -> normal bool (for comparison)

Writing:
1.903 s -> BoolArray class

0.783 s -> normal bool

RandoMovie

December 20th, 2010

Today I have a problem with choosing which movie to watch, so I’ve written a small program to solve that problem. It is still unfinished, but its basic functions work properly. I’ve also made it idiot-proof (if you find any bug, please report me).

Here’s the download:

RandoMovie 1.1 (x64 version)

RandoMovie 1.1 (x86 version)

You will also need .NET 4.0.

AntAlgorithms

October 20th, 2010

Some time ago, I’ve written a program for solving the salesman problem by means of the ant algorithms.

The program is available here: http://sourceforge.net/projects/antalgorithm/.

Code for Qt is here: http://sourceforge.net/projects/antalgorithm/files/sources/ant_algorithms_source.zip/download.

If you want to read a manual you go here: http://sourceforge.net/projects/antalgorithm/files/manual/manual.pdf/download.

BoolArray class

February 19th, 2010

An array of many bool variables takes much space. Bool is such a variable, that can be saved using one bit only. Under x86 architecture smallest memory chunk, that can be allocated, is one byte. We are losing 7 bits in every bool variable. in 1000 - element array that’s 7000 bits - 875 bytes. We are wasting 87.5% of memory.

My BoolArray class solves the problem. It can be pretty much improved (especially by overloading operators), but now it works properly.

Three of its features are quite remarkable: the extended functions, customizable size and file functions.

1. Extended Functions - Turned on by:

#define EXTENDED_BOOL_FUNCTIONS

Without the preprocessor instruction the class is minimized to simplest methods only, such as getValue(), setValue(). When the instruction is enabled, the class increases its complexity, covering many possible uses.

2. Customizable size - set by:

#define SIZE_SMALL

(or SIZE_MEDIUM, or SIZE_BIG)

SIZE_SMALL - size is stored in a char variable

SIZE_MEDIUM - size is stored in a int variable

SIZE_BIG - size is stored in a long variable

By default the size is set to SIZE_SMALL.

3. File functions - enable saving and reading from a file. Enabled by including <fstream> BEFORE including “boolean.h”. Tested in MinGW, should work in gcc & DJGPP, in other compilers the programmer may need to check the constant name defined in fstream - here it’s _GLIBCXX_FSTREAM.

Especially the toFileAndFree function is worth mentioning. It saves the array contents on hard disk, and frees the memory. It could be very useful in resources managing.

BoolArray - here’s the download link.

Exemplary Use - a source file with exemplary use of the class.

Please send me the information about found bugs & possible improvements.