Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
TVector
/** \file TVector.c * \brief Implementace Basic Vector API * \author Edo Harbaľ * \version 2022 * $Id: TVector.c 1023 2021-02-08 09:42:15Z petyovsky $ */ #include <stdlib.h> #include <assert.h> #include "TVector.h" #include "check.h" bool vector_init(struct TVector *aVector, size_t aSize)//Dynamicky alokuje paměť pro pole o zadaném počtu elementů, inicializuje elementy na hodnotu 0. { if(!aVector) return false; TVectorElement *new_values = NULL; if(aSize) { new_values = calloc(aSize, sizeof(TVectorElement)); if(!new_values) return false; } *aVector = (struct TVector) {.iValues = new_values, .iSize = aSize}; return true; } bool vector_init_random(struct TVector *aVector, size_t aSize)//Dynamicky alokuje paměť pro pole o zadaném počtu elementů, inicializuje elementy na náhodné hodnoty. { if(!aVector) return false; TVectorElement *new_values = NULL; if(aSize) { new_values = malloc(aSize * sizeof(TVectorElement)); if(!new_values) return false; for(size_t i = 0; i < aSize; ++i) new_values[i] = vector_element_random_value(); } *aVector = (struct TVector) {.iValues = new_values, .iSize = aSize}; return true; } bool vector_init_file(struct TVector *aVector, FILE *aInputFile)//Načte ze souboru počet elementů vektoru, //dynamicky alokuje paměť pro vektor o načteném počtu elementů, načte ze souboru hodnoty jednotlivých elementů. { if(!aVector || !aInputFile) //ověřuji zda jsou platne return false; size_t new_size = 0; if(fscanf(aInputFile, "%zu", &new_size) != 1) //čtu novy počet hodnot return false; TVectorElement *new_values = NULL; if(aSize) { new_values = malloc(aSize * sizeof(TVectorElement)); if(!new_values) return false; for(size_t i = 0; i < aSize; ++i) if(!vector_element_load_file(&new_values[i], aInputFile)) { free(new_values); return false; } } *aVector = (struct TVector) {.iValues = new_values, .iSize = aSize}; return true; } bool vector_clone(const struct TVector *aVector, struct TVector *aVectorClone) { return false; } bool vector_store_file(const struct TVector *aVector, FILE *aOutputFile) { return false; } TVectorElement vector_value(const struct TVector *aVector, size_t aPos) { return (TVectorElement) { 0 }; } void vector_set_value(struct TVector *aVector, size_t aPos, TVectorElement aValue) { } size_t vector_size(const struct TVector *aVector) { return 0; } bool vector_resize(struct TVector *aVector, size_t aNewSize) { return false; } void vector_destroy(struct TVector *aVector) { } //Tady skoncit struct TVectorIterator vector_iterator_begin(const struct TVector *aVector) { return (struct TVectorIterator) { .iVector = NULL, .iPos = 0 }; } struct TVectorIterator vector_iterator_pos(const struct TVector *aVector, size_t aPos) { return (struct TVectorIterator) { .iVector = NULL, .iPos = 0 }; } bool vector_iterator_is_valid(const struct TVectorIterator *aIter) { return false; } bool vector_iterator_to_next(struct TVectorIterator *aIter) { return false; } bool vector_iterator_to_prev(struct TVectorIterator *aIter) { return false; } TVectorElement vector_iterator_value(const struct TVectorIterator *aIter) { return (TVectorElement) { 0 }; } bool vector_iterator_set_value(const struct TVectorIterator *aIter, TVectorElement aValue) { return false; }
run
|
edit
|
history
|
help
0
tiskunti retezcu a zmena pismenke z malych an velke
pointery
arraywithqueue
array of structures
TStack_array
matice
Retezce live
pokus
stdio.h
Tisknuti retezcu a zmnena pismenek z v na m