INGOR
Loading...
Searching...
No Matches
ytArray.h
1;;/*
2 ytArray.{h,c} : Expanable ytObject * 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__ARRAY_H
37#define __YTLIB__ARRAY_H
38
39#include <stdio.h>
40#include <stdlib.h>
41
42#include "lang/ytObject.h"
43
44#define ytArray_ERROR_VALUE ((size_t) -1)
45
50/*typedef struct ytArray_t ytArray;*/
51#ifndef DOXY
52typedef struct ytArray_t {
53 ytObject obj;
54 ytObject * * ptr;
55 size_t size;
56 size_t buff_size;
57} ytArray;
58#endif
59
60#ifdef YTLIB_MEMCHECK
61#define ytArray_new() ytArray_newm(__FILE__,__LINE__)
62ytArray * ytArray_newm(const char * file, int line);
63#else
64ytArray * ytArray_new();
65#endif
66void ytArray_delete(ytArray * this);
67void ytArray_deletev(void * this);
68void ytArray_deleteAll(ytArray * this);
69void ytArray_deleteAllv(void * this);
70ytArray * ytArray_clone(const ytArray * this);
71ytObject * ytArray_cloneI(const ytObject * this);
72ytArray * ytArray_arrayNew(size_t size);
73void ytArray_arrayDelete(ytArray * this, size_t size);
74void ytArray_dump(const ytArray * this, FILE * fp);
75void ytArray_dumpv(const ytObject * this, FILE * fp);
76size_t ytArray_size(const ytArray * this);
77size_t ytArray_buffSize(const ytArray * this);
78size_t ytArray_memSize(const ytArray * this);
79size_t ytArray_arrayMemSize(const ytArray * this, size_t n);
80void ytArray_clear(ytArray * this);
81ytArray * ytArray_setBuffSize(ytArray * this, size_t new_size);
82void ytArray_add(ytArray * this, ytObject * value);
83void ytArray_addArray(ytArray * this, const ytArray * values);
84void ytArray_set(ytArray * this, size_t index, ytObject * value);
85void ytArray_setSize(ytArray * this, size_t size);
86void ytArray_insert(ytArray * this, size_t index, ytObject * value);
87ytObject * ytArray_remove(ytArray * this, size_t index);
88void ytArray_copy(ytArray * this, const ytArray * src);
89void ytArray_copyArray(ytArray * this, size_t index, const ytObject * * array, size_t size);
90ytObject * ytArray_get(const ytArray * this, size_t index);
91ytObject * ytArray_pop(ytArray * this);
92ytObject * * ytArray_ptr(ytArray * this);
93void ytArray_sort(ytArray * this);
94size_t ytArray_find(const ytArray * this, const ytObject * v);
95void ytArray_print(const ytArray * this, FILE * fp, char * delim);
96int ytArray_sprint(const ytArray * this, char * buff, size_t size, char * delim);
97ytObject * ytArray_obj(ytArray * this);
98ytObject * ytArray_pObj(ytArray ** ptr);
99ytArray * ytArray_from(ytObject * this);
100ytArray ** ytArray_objP(ytObject * this);
101size_t ytArray_memorySize(const ytArray * this);
102size_t ytArray_memorySizeI(const ytObject * this);
103ytByte * ytArray_serializeI(const ytObject * obj, ytByte ** pptr);
104ytByte * ytArray_serialize(const ytArray * this, ytByte ** pptr);
105ytArray * ytArray_deserialize(ytByte ** const pptr);
106ytObject * ytArray_deserializeI(ytByte ** const ptr);
107#ifdef USE_MPI
108#include <mpi.h>
109void ytArray_MPI_Bcast(ytArray ** pObj, int root, MPI_Comm comm);
110void ytArray_MPI_BcastI(ytObject ** pObject, int root, MPI_Comm comm);
111#endif
112
113#endif /* __YTLIB__ARRAY_H */
Expandable array.
The basis class.