Skip to content

Commit

Permalink
Documented some of foundation classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
m1maker committed Oct 26, 2024
1 parent 3dd2c4d commit a39c2b9
Show file tree
Hide file tree
Showing 22 changed files with 2,167 additions and 267 deletions.
65 changes: 65 additions & 0 deletions docs/Foundation/Namespaces/Global/Classes/any.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Class: any

The `any` class provides a data structure that can hold and manage values of different types in NGT. It allows for flexible storage and retrieval of various data types.

## Constructors

### `any()`
- **Description**: Constructs an empty `any` object.

### `any(?&in value)`
- **Parameters**:
- `value` (?&): A value to store.
- **Description**: Constructs a new `any` object and stores the specified value.

### `any(const int64&in value)`
- **Parameters**:
- `value` (const int64&): An integer value to store.
- **Description**: Constructs a new `any` object and stores the specified integer value.

### `any(const double&in value)`
- **Parameters**:
- `value` (const double&): A floating-point value to store.
- **Description**: Constructs a new `any` object and stores the specified floating-point value.


## Methods

### `any& opAssign(any&in other)`
- **Parameters**:
- `other` (any&): The other `any` object to assign.
- **Return Type**: any&
- **Description**: Assigns the contents of another `any` object to this one and returns a reference to this object.

### `void store(?&in value)`
- **Parameters**:
- `value` (?&): A value to store.
- **Description**: Stores the specified value in the `any` object.

### `void store(const int64&in value)`
- **Parameters**:
- `value` (const int64&): An integer value to store.
- **Description**: Stores the specified integer value in the `any` object.

### `void store(const double&in value)`
- **Parameters**:
- `value` (const double&): A floating-point value to store.
- **Description**: Stores the specified floating-point value in the `any` object.

### `bool retrieve(?&out result)`
- **Parameters**:
- `result` (?&out): Output parameter for the retrieved value.
- **Return Type**: bool
- **Description**: Retrieves the stored value and assigns it to the output parameter. Returns `true` if successful; otherwise, returns `false`.

### `bool retrieve(int64&out result)`
- **Parameters**:
- `result` (int64&out): Output parameter for the retrieved integer value.
- **Return Type**: bool
- **Description**: Retrieves the stored integer value and assigns it to the output parameter. Returns `true` if successful; otherwise, returns `false`.

### `bool retrieve(double&out result)`
- **Parameters**:
- `result` (double&out): Output parameter for the retrieved floating-point value.
- **Return Type**: bool
- **Description**: Retrieves the stored floating-point value and assigns it to the output parameter. Returns `true` if successful; otherwise, returns `false`.
155 changes: 155 additions & 0 deletions docs/Foundation/Namespaces/Global/Classes/array.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# Class: array<T>

The `array<T>` class provides a dynamic array data structure in NGT. It supports various operations for managing and manipulating arrays of any type `T`.

## Constructors

### `array<T>()`
- **Description**: Constructs an empty array.

### `array<T>(int&in length)`
- **Parameters**:
- `length` (int): The initial length of the array.
- **Description**: Constructs an array with the specified initial length, filled with default values.

### `array<T>(int&in length, const T&in value)`
- **Parameters**:
- `length` (int): The initial length of the array.
- `value` (const T&): The value to fill the array with.
- **Description**: Constructs an array with the specified initial length, filled with the given value.

### `$list(int&in start, int&in count) { repeat T }`
- **Parameters**:
- `start` (int): The starting index.
- `count` (int): The number of elements to create.
- **Return Type**: array<T>
- **Description**: Creates and returns a new array with the specified range.

## Methods

### `T& opIndex(uint index)`
- **Parameters**:
- `index` (uint): The index to access.
- **Return Type**: T&
- **Description**: Provides indexed access to the array. Returns a reference to the element at the specified index.

### `const T& opIndex(uint index) const`
- **Parameters**:
- `index` (uint): The index to access.
- **Return Type**: const T&
- **Description**: Provides indexed access to the array in a read-only manner. Returns a reference to the element at the specified index.

### `array<T>& opAssign(const array<T>&in other)`
- **Parameters**:
- `other` (const array<T>&): The other array to assign.
- **Return Type**: array<T>&
- **Description**: Assigns the contents of another array to this array and returns a reference to this array.

### `void insert_at(uint index, const T&in value)`
- **Parameters**:
- `index` (uint): The index at which to insert.
- `value` (const T&): The value to insert.
- **Description**: Inserts a new element into the array at the specified index.

### `void insert_at(uint index, const array<T>&inout arr)`
- **Parameters**:
- `index` (uint): The index at which to insert.
- `arr` (const array<T>&inout): The array to insert.
- **Description**: Inserts another array into this array at the specified index.

### `void insert_last(const T&in value)`
- **Parameters**:
- `value` (const T&): The value to insert at the end of the array.
- **Description**: Appends a new element to the end of the array.

### `void remove_at(uint index)`
- **Parameters**:
- `index` (uint): The index of the element to remove.
- **Description**: Removes the element at the specified index from the array.

### `void remove_last()`
- **Description**: Removes the last element from the array.

### `void remove_range(uint start, uint count)`
- **Parameters**:
- `start` (uint): The starting index of the range to remove.
- `count` (uint): The number of elements to remove.
- **Description**: Removes a specified range of elements from the array.

### `uint length() const`
- **Return Type**: uint
- **Description**: Returns the current length of the array.

### `void reserve(uint length)`
- **Parameters**:
- `length` (uint): The new minimum capacity to reserve for the array.
- **Description**: Reserves enough space in the array to hold at least the specified number of elements without reallocation.

### `void resize(uint length)`
- **Parameters**:
- `length` (uint): The new size for the array.
- **Description**: Changes the size of the array. If the new size is larger than the current capacity, the array will be resized to accommodate it.

### `void sort_asc()`
- **Description**: Sorts the elements in ascending order.

### `void sort_asc(uint startAt, uint count)`
- **Parameters**:
- `startAt` (uint): The starting index for sorting.
- `count` (uint): The number of elements to sort.
- **Description**: Sorts a specified range of elements in the array in ascending order.

### `void sort_desc()`
- **Description**: Sorts the elements in descending order.

### `void sort_desc(uint startAt, uint count)`
- **Parameters**:
- `startAt` (uint): The starting index for sorting.
- `count` (uint): The number of elements to sort.
- **Description**: Sorts a specified range of elements in the array in descending order.

### `void reverse()`
- **Description**: Reverses the order of the elements in the array.

### `int find(const T&in value) const`
- **Parameters**:
- `value` (const T&): The value to search for.
- **Return Type**: int
- **Description**: Searches for the specified value in the array and returns its index if found; otherwise, returns `-1`.

### `int find(uint startAt, const T&in value) const`
- **Parameters**:
- `startAt` (uint): The starting index for search.
- `value` (const T&): The value to search for.
- **Return Type**: int
- **Description**: Searches for the specified value in a specified range of the array and returns its index if found; otherwise, returns `-1`.

### `int find_by_ref(const T&in value) const`
- **Parameters**:
- `value` (const T&): The value to search for.
- **Return Type**: int
- **Description**: Searches for the specified value in the array using reference equality and returns its index if found; otherwise, returns `-1`.

### `int find_by_ref(uint startAt, const T&in value) const`
- **Parameters**:
- `startAt` (uint): The starting index for search.
- `value` (const T&): The value to search for.
- **Return Type**: int
- **Description**: Searches for the specified value in a specified range of the array using reference equality and returns its index if found; otherwise, returns `-1`.

### `bool op_equals(const array<T>&in other) const`
- **Parameters**:
- `other` (const array<T>&): The other array to compare.
- **Return Type**: bool
- **Description**: Compares this array with another array for equality and returns `true` if they are equal; otherwise, returns `false`.

### `bool is_empty() const`
- **Return Type**: bool
- **Description**: Checks if the array is empty and returns `true` if it is; otherwise, returns `false`.

### `void sort(array<T>::less&in comparer, uint startAt = 0, uint count = uint (-1))`
- **Parameters**:
- `comparer` (array<T>::less&): The comparison function object.
- `startAt` (uint): The starting index for sorting (default is `0`).
- `count` (uint): The number of elements to sort (default is the entire array).
- **Description**: Sorts the array using a custom comparison function.
117 changes: 117 additions & 0 deletions docs/Foundation/Namespaces/Global/Classes/complex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Class: complex

The `complex` class provides a data structure for representing complex numbers in NGT. It supports operations for basic arithmetic and accessing the real and imaginary parts of complex numbers.

## Constructors

### `void $list(const int&in count) { float, float }`
- **Parameters**:
- `count` (int): The number of complex numbers to initialize.
- **Description**: Initializes an array of complex numbers with the specified count.

### `complex()`
- **Description**: Constructs a default complex number with zero real and imaginary parts.

### `complex(const complex&in other)`
- **Parameters**:
- `other` (const complex&): The other complex number to copy.
- **Description**: Constructs a new complex number by copying another one.

### `complex(float value)`
- **Parameters**:
- `value` (float): The real part of the complex number.
- **Description**: Constructs a complex number with the specified real part and zero imaginary part.

### `complex(float real, float imag)`
- **Parameters**:
- `real` (float): The real part of the complex number.
- `imag` (float): The imaginary part of the complex number.
- **Description**: Constructs a complex number with the specified real and imaginary parts.

## Methods

### `complex& opAddAssign(const complex&in other)`
- **Parameters**:
- `other` (const complex&): The other complex number to add.
- **Return Type**: complex&
- **Description**: Adds another complex number to this one and returns a reference to this object.

### `complex& opSubAssign(const complex&in other)`
- **Parameters**:
- `other` (const complex&): The other complex number to subtract.
- **Return Type**: complex&
- **Description**: Subtracts another complex number from this one and returns a reference to this object.

### `complex& opMulAssign(const complex&in other)`
- **Parameters**:
- `other` (const complex&): The other complex number to multiply by.
- **Return Type**: complex&
- **Description**: Multiplies this complex number by another and returns a reference to this object.

### `complex& opDivAssign(const complex&in other)`
- **Parameters**:
- `other` (const complex&): The other complex number to divide by.
- **Return Type**: complex&
- **Description**: Divides this complex number by another and returns a reference to this object.

### `bool opEquals(const complex&in other) const`
- **Parameters**:
- `other` (const complex&): The other complex number to compare with.
- **Return Type**: bool
- **Description**: Compares this complex number with another for equality and returns `true` if they are equal; otherwise, returns `false`.

### `complex opAdd(const complex&in other) const`
- **Parameters**:
- `other` (const complex&): The other complex number to add.
- **Return Type**: complex
- **Description**: Creates a new complex number by adding this one and another.

### `complex opSub(const complex&in other) const`
- **Parameters**:
- `other` (const complex&): The other complex number to subtract.
- **Return Type**: complex
- **Description**: Creates a new complex number by subtracting another from this one.

### `complex opMul(const complex&in other) const`
- **Parameters**:
- `other` (const complex&): The other complex number to multiply by.
- **Return Type**: complex
- **Description**: Creates a new complex number by multiplying this one by another.

### `complex opDiv(const complex&in other) const`
- **Parameters**:
- `other` (const complex&): The other complex number to divide by.
- **Return Type**: complex
- **Description**: Creates a new complex number by dividing this one by another.

### `float abs() const`
- **Return Type**: float
- **Description**: Returns the absolute value of the complex number.

### `complex get_ri() const property`
- **Return Type**: complex
- **Description**: Returns the real part of the complex number as a property.

### `complex get_ir() const property`
- **Return Type**: complex
- **Description**: Returns the imaginary part of the complex number as a property.

### `void set_ri(const complex&in value) property`
- **Parameters**:
- `value` (const complex&): The new real part to set.
- **Description**: Sets the real part of the complex number using a property.

### `void set_ir(const complex&in value) property`
- **Parameters**:
- `value` (const complex&): The new imaginary part to set.
- **Description**: Sets the imaginary part of the complex number using a property.

## Properties

### `r`
- **Type**: float
- **Description**: A property representing the real part of the complex number.

### `i`
- **Type**: float
- **Description**: A property representing the imaginary part of the complex number.
Loading

0 comments on commit a39c2b9

Please sign in to comment.