amalthea.dataprocessing

This file is part of the Amalthea library. Copyright (C) 2018-2024 Eugene 'Vindex' Stulin Distributed under the BSL 1.0 or (at your option) the GNU LGPL 3.0 or later.

The module contains some useful functions for data processing, including functions for working with dynamic arrays and associative arrays, functions for working with command line arguments, operations on arrays as sets, some functions for working with strings, etc.

Public Imports

amalthea.libcore
public import amalthea.libcore;
Undocumented in source.

Members

Aliases

extractValueForFlag
alias extractValueForFlag = extractOptionValue
Undocumented in source.
getValueForFlag
alias getValueForFlag = getOptionValue
Undocumented in source.
toOctalString
alias toOctalString = getOctalForm
Undocumented in source.

Functions

assocArrayItems
auto assocArrayItems(V[K] aarray)

Returns array of tuples with pairs of keys and values from associative array.

calcComplement
T calcComplement(T[] arrays)

Implementation of the complement operation for arrays.

calcIntersection
T calcIntersection(T[] arrays)

Implementation of the intersection operation for arrays.

calcUnion
T calcUnion(T[] arrays)

Implementation of the union operation for arrays.

convJSONValueToDouble
double convJSONValueToDouble(std.json.JSONValue json)

The function converts JSONValue to double.

copyArray
T[] copyArray(T[] arr)

Creates a new dynamic array of the same size and copies the contents of the dynamic array into it. This function supports arrays with complex constant structures, unlike the 'dup' function.

countElements
size_t countElements(R range, E value)

Counts the number of required elements in a range.

divideByElemNumber
T[] divideByElemNumber(T arr, size_t n)

Divides an array: makes a new array of arrays containing elements from source array. Each subarray contains specified number of elements.

extractOptionRange
string[] extractOptionRange(string[] args, string flag, string altFlag)

Function for extracting of value as array by flag. Unlike getOptionRange(), this function changes the passed arguments (args), removing the flag with a value.

extractOptionValue
string extractOptionValue(string[] args, string flag, string altFlag)

Function for extracting of value by flag. Unlike getOptionValue(), this function changes the passed args, removing the flag with a value.

getBinaryForm
string getBinaryForm(ulong value)

The function converts integer number into an binary form.

getIndex
ssize_t getIndex(T[] haystack, T needle)

The function returns the index of the array element by value.

getOctalForm
string getOctalForm(ulong value)

The function converts integer number into an octal form, returns as a string.

getOptionRange
string[] getOptionRange(string[] args, string flag, string altFlag)

Function to get values as array by flag.

getOptionValue
string getOptionValue(string[] args, string flag, string altFlag)

Function to get a value by parameter. Used to process command line arguments.

isAmong
bool isAmong(Value value, Values values)
bool isAmong(T value, T[] values)

The function similar to functions "canFind" and "among".

makeFilledArray
T[] makeFilledArray(size_t len, T filler)

Creates new array with specified content.

mixAssociativeArrays
V[K] mixAssociativeArrays(V[K] firstArray, V[K] secondArray)

This function combines two associative arrays, returns new associative array. If two arrays have the same keys, the values from the first array are used.

orderAssociativeArray
deprecated void orderAssociativeArray(V[K] aarray, K[] orderedKeys, V[] orderedValues)

The function arranges the associative array by the required sorting method (string "by" is equal to "values" or "keys"), returns an array of keys and an array of values.

orderAssociativeArrayByKeys
deprecated void orderAssociativeArrayByKeys(V[K] aarray, K[] orderedKeys, V[] orderedValues)

The function arranges the associative array by keys, returns an array of keys and an array of values.

orderAssociativeArrayByValues
deprecated void orderAssociativeArrayByValues(V[K] aarray, K[] orderedKeys, V[] orderedValues)

The function arranges the associative array by values, returns an array of keys and an array of values.

removeDuplicate
T[] removeDuplicate(T[] arr)

The function removes duplicate elements from an array.

removeDuplicateConsecutiveSubstring
string removeDuplicateConsecutiveSubstring(string s, string substring)

The function removes consecutive string duplicates.

removeElementsByContent
T[] removeElementsByContent(T[] haystack, T needle)

The function returns an array without unnecessary elements.

sortAssocArrayItemsByKeys
auto sortAssocArrayItemsByKeys(V[K] aarray, Flag!"desc" desc)

Makes key-sorted array of tuples with pairs of keys and values from associative array.

sortAssocArrayItemsByValues
auto sortAssocArrayItemsByValues(V[K] aarray, Flag!"desc" desc)

Makes value-sorted array of tuples with pairs of keys and values from associative array.

stripLeft
string stripLeft(string line, char symbol)
string stripLeft(string line, char[] symbols)

Cuts off consecutive unnecessary characters from the left side.

stripRight
string stripRight(string line, char symbol)
string stripRight(string line, char[] symbols)

Cuts off consecutive unnecessary characters from the right side.

urlEncode
string urlEncode(string[string] values)

Encode associative array using www-form-urlencoding (copied from std.uri).

Meta