INGOR
Loading...
Searching...
No Matches
ytDoubleArray.h
1/*
2 ytDoubleArray.{h,c} : Expanable double Array
3 Copyright (C) 2016, Yoshinori Tamada <tamada A T ytlab.jp>
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9
10 * Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12
13 * Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in
15 the documentation and/or other materials provided with the
16 distribution.
17
18 * Neither the name of Kyoto University nor the names of its
19 contributors may be used to endorse or promote products derived
20 from this software without specific prior written permission.
21
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 POSSIBILITY OF SUCH DAMAGE.
34*/
35
36#ifndef __YTLIB_DOUBLE_ARRAY_H
37#define __YTLIB_DOUBLE_ARRAY_H
38
39#include <stdio.h>
40#include <stdlib.h>
41
42#include "lang/ytObject.h"
43
44#define ytDoubleArray_ERROR_VALUE ((size_t) -1)
45
50/*typedef struct ytDoubleArray_t ytDoubleArray;*/
51#ifndef DOXY
52typedef struct ytDoubleArray_t {
53 ytObject obj;
54 double * ptr;
55 size_t size;
56 size_t buff_size;
58#endif
59
60#ifdef YTLIB_MEMCHECK
61#define ytDoubleArray_new() ytDoubleArray_newm(__FILE__,__LINE__)
62ytDoubleArray * ytDoubleArray_newm(const char * file, int line);
63#else
64ytDoubleArray * ytDoubleArray_new();
65#endif
66void ytDoubleArray_delete(ytDoubleArray * this);
67void ytDoubleArray_deletev(void * this);
68void ytDoubleArray_deleteAll(ytDoubleArray * this);
69void ytDoubleArray_deleteAllv(void * this);
70ytDoubleArray * ytDoubleArray_clone(const ytDoubleArray * this);
71ytObject * ytDoubleArray_cloneI(const ytObject * this);
72ytDoubleArray * ytDoubleArray_arrayNew(size_t size);
73void ytDoubleArray_arrayDelete(ytDoubleArray * this, size_t size);
74void ytDoubleArray_dump(const ytDoubleArray * this, FILE * fp);
75void ytDoubleArray_dumpv(const ytObject * this, FILE * fp);
76size_t ytDoubleArray_size(const ytDoubleArray * this);
77size_t ytDoubleArray_buffSize(const ytDoubleArray * this);
78size_t ytDoubleArray_memSize(const ytDoubleArray * this);
79size_t ytDoubleArray_arrayMemSize(const ytDoubleArray * this, size_t n);
80void ytDoubleArray_clear(ytDoubleArray * this);
81ytDoubleArray * ytDoubleArray_setBuffSize(ytDoubleArray * this, size_t new_size);
82void ytDoubleArray_add(ytDoubleArray * this, double value);
83void ytDoubleArray_addDoubleArray(ytDoubleArray * this, const ytDoubleArray * values);
84void ytDoubleArray_set(ytDoubleArray * this, size_t index, double value);
85void ytDoubleArray_setSize(ytDoubleArray * this, size_t size);
86void ytDoubleArray_insert(ytDoubleArray * this, size_t index, double value);
87double ytDoubleArray_remove(ytDoubleArray * this, size_t index);
88void ytDoubleArray_copy(ytDoubleArray * this, const ytDoubleArray * src);
89void ytDoubleArray_copyArray(ytDoubleArray * this, size_t index, const double * array, size_t size);
90double ytDoubleArray_get(const ytDoubleArray * this, size_t index);
91double ytDoubleArray_pop(ytDoubleArray * this);
92double * ytDoubleArray_ptr(ytDoubleArray * this);
93void ytDoubleArray_sort(ytDoubleArray * this);
94size_t ytDoubleArray_find(const ytDoubleArray * this, const double v);
95void ytDoubleArray_print(const ytDoubleArray * this, FILE * fp, char * delim);
96int ytDoubleArray_sprint(const ytDoubleArray * this, char * buff, size_t size, char * delim);
97ytObject * ytDoubleArray_obj(ytDoubleArray * this);
98ytObject * ytDoubleArray_pObj(ytDoubleArray ** ptr);
99ytDoubleArray * ytDoubleArray_from(ytObject * this);
100ytDoubleArray ** ytDoubleArray_objP(ytObject * this);
101size_t ytDoubleArray_memorySize(const ytDoubleArray * this);
102size_t ytDoubleArray_memorySizeI(const ytObject * this);
103ytByte * ytDoubleArray_serializeI(const ytObject * obj, ytByte ** pptr);
104ytByte * ytDoubleArray_serialize(const ytDoubleArray * this, ytByte ** pptr);
105ytDoubleArray * ytDoubleArray_deserialize(ytByte ** const pptr);
106ytObject * ytDoubleArray_deserializeI(ytByte ** const ptr);
107#ifdef USE_MPI
108#include <mpi.h>
109void ytDoubleArray_MPI_Bcast(ytDoubleArray ** pObj, int root, MPI_Comm comm);
110void ytDoubleArray_MPI_BcastI(ytObject ** pObject, int root, MPI_Comm comm);
111#endif
112
113#endif /* __YTLIB_DOUBLE_ARRAY_H */
Expandable array.
The basis class.