This is a repository, where I store the tasks on my General Programming university course.
This task is dedicated to implementation of a Stack data structure in C programming language. The task is divided in several parts:
-
stack with capability to store only integer nubers;
-
stack with capability to store any type of data.
The both stacks have standard functionality to push (add an element), pop (delete an element), top (check the uppermost element), and create and desroy the stack.
The first part pf the task is completed in grindelf-stack-int header and source code files and simply stores integers as an array (a pointer to the integer value).
The second part is completed in grindelf-stack header and source code files and uses the
void *pointer to store the values of different types.
The task is to create an implementation of a vector data structure in C programming language. Like the previous one the task is divided in several parts:
-
vector with capability to store only integer nubers;
-
vector with capability to store any type of data.
The both vectors have standard functionality to get data from the vector, to resize the vector, to append to the vector and to insert to the vector, as well as to create and to destroy the vector itself.
Create a C++ template function dremove, which will be able to remove all occurances of arbitrary value from provided range [start, fin] of a container type, e.g. list or vector. It will have following signature:
template<typename T, typename I>
I dremove(I start, I fin, T value);where I are iterators' type and T is the container’s values type.
The function should use iterators and should place one after the last element of the updated container with removed value instances.
Create a C++ template function dremoveIf, which will be able to remove all occurances of values from provided range [start, fin] of a container type which fit some given condition pred. It will have following signature:
template<typename P, typename I>
I dremoveIf(I start, I fin, P pred);where I are iterators' type and P is the type of predicate condition.
The function should use iterators and should place one after the last element of the updated container with removed value instances.
Create a C++ template function transform, which will be able to apply some function of type F to each value from provided range [start, fin]. It will have following signature:
template<typename I, typename F>
I transform(I start, I fin, F fucnt);where I are iterators' type and F is the type of the function. The function operates with values of type T which is not provided as a template.
The function should use iterators and should place one after the last element of the new container.
With a given set of segments (eg [1, 2], [7, 2]) make set of broken lines formed by this segments (in the case of this example it will be [1, 2, 7]). The segments can lead to cyucled broken lines but broken lines may not have branches.
!! INFO: std::map is ordered by default, and because of that key type can only be those types, which have < operator.
Task: create a program, which produces a frequency dictionary.
Create the gunique::unique(it1, it2, it_out) function, which will return iterator for the container with only unique values of the initial container. The initial container is ordered.
E.g.: {1, 2, 2, 3, 3, 5} → {1, 2, 3, 5}.
Create the gunique::unique2(it1, it2, it_out) function, which will return iterator for the container with only unique values of the initial container. This time the initial container is not oredered. Nontheless, the complexity should be linear, not squared.
E.g.: {7, 1, 5, 1, 2, 3, 2} → {7, 1, 5, 2, 3}.
Implement function public static IEnumerate<T> Transform:
public static IEnumerate<T> Transform<T>(this IEnumerable<T> collection, Func<T, T> transformer);This function updates the initial collection values with some function 'transformer' and returns updated values.
Implement function public static IEnumerate<T> Filter:
public static IEnumerate<T> Filter<T>(this IEnumerable<T> collection, Predicate<int> predicate);This function filters initial collection and returns values that satisfy the given predicate.
Implement function public static T Reduce:
public static T Reduce<T>(this IEnumerable<T>, Func<T, T, T> func);This function reduces all the values of a collection to one value.
Implement function public static IEnumerate<T> Unique:
public static IEnumerate<T> Unique<T>(this IEnumerable<T> collection);This function filters initial collection (ordered) and returns only unique values.
Implement function public static IEnumerate<T> Unique2:
public static IEnumerate<T> Unique2<T>(this IEnumerable<T> collection);This function filters unordered initial collection and returns only unique values. Requirement: the function must perform the job with linear time.
Find predecessors for each Civilization 2 skill and build sets, where Set A contains skills that do not require other skills to be learned before learning it, Set B contains skills that require predecessor-skills only from Set A, Set C contains skills that require predecessor-skills from Set B and Set A and so on. The program should output the file containing the skills ordered in a described way.