1 ----------------------------------------------------------------------------
3 Documentation of miscellaneous shared include files
5 ----------------------------------------------------------------------------
10 Located in IVAN/Include, these files contain some standard classes and
11 small, convenient inline routines that are commonly used in every IvenDev
17 dynarray<class Type, class SizeType = ushort>
18 ---------------------------------------------
20 A class template that was a kind of substite for vector when IvanDev
21 knew not how to use it :) Type is the type of one element, SizeType
22 is the type in which the size of the array is measured.
28 Creates a new, empty dynarray.
30 dynarray(const dynarray<Type, SizeType>* Array)
32 Creates a new dynarray and copies its initial data from Array.
36 Detroys dynarray and its elements.
38 Type& Access(SizeType Index)
40 Access element of Index. May crash if Index greater than or equal
45 Returns the current number of elements.
49 Adds Element to the end of dynarray.
51 Add(const dynarray<Type, SizeType>* DynArray)
53 Adds the entire contents of DynArray to the end of dynarray.
55 Put(Type Element, SizeType Position)
57 Makes Access[Position] henceforth return Element. All elements
58 beyound Position are pushed forward. May crash if Position
59 is greater than or equal to Length().
61 Type Remove(SizeType Index)
63 Erases the Element of Index and returns it. All elements beyound
64 Index are pulled backwards.
66 Type& operator [] (SizeType Index)
70 Type& operator << (Type& Element)
74 SizeType Search(Type Element)
76 If an element equal to Element is found in the dynarray, returns
77 its index, otherwise returns -1 converted to SizeType. Type
78 must support the logical == operator.
80 Resize(SizeType NewSize)
82 Forces Length() henceforth return NewSize. All elements beyound
83 this length are erased. If Length() is less than NewSize, new
84 elements are filled with rubbish.
89 The basic two-dimensional vector class, i.e. a mathematical object with
90 scalar X and Y elements.
96 Constructs a vector with undefined elements.
98 vector(ushort X, ushort Y)
100 Constructs a vector with specified elements.
102 vector operator + (const vector& H)
103 vector& operator += (const vector& H)
104 vector& operator = (const vector& H)
105 bool operator == (const vector& H)
106 bool operator != (const vector& H)
108 Self-explanatory overloaded math operators.
116 template <class Type> Type** Alloc2D(ulong XSize, ulong YSize)
118 Allocates a two-dimensional block of type Type and size of
119 XSize * YSize. The Block can be deleted via a simple delete []
120 operator, but it cannot be resized without reallocation.
124 int** Map = Alloc2D<int>(3,4);
126 std::cout << Map[2][3] << std::endl;
129 Result: "666" is output.
134 template <class Type> Type GetHypotSquare(Type X, Type Y)
136 Returns the hypotenuse of a rigth-angle triangle of short sides
137 X & Y raised to the power of two, i.e. X*X + Y*Y.
142 std::string operator+ (std::string String, const int& Int)
144 Overloaded string operator that transforms numeric Int into
145 a string and adds it to String temporarily, returning the result.
147 std::string& operator+= (std::string& String, const int& Int)
149 Transforms numeric Int into a string and adds it to String
150 permanently, returning the result.
152 std::ofstream& operator+= (std::ofstream& File, const std::string& String)
154 Saves String into a File.
156 std::string& operator-= (std::ifstream& File, std::string& String)
158 Loads String from a File.
160 ----------------------------------------------------------------------------