INGOR
Loading...
Searching...
No Matches
ytIntArray.h
1/*
2 ytIntArray.{h,c} : Expanable int 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_INT_ARRAY_H
37#define __YTLIB_INT_ARRAY_H
38
39#include <stdio.h>
40#include <stdlib.h>
41
42#include "lang/ytObject.h"
43
44#define ytIntArray_ERROR_VALUE ((size_t) -1)
45
50/*typedef struct ytIntArray_t ytIntArray;*/
51#ifndef DOXY
52typedef struct ytIntArray_t {
53 ytObject obj;
54 int * ptr;
55 size_t size;
56 size_t buff_size;
58#endif
59
60#ifdef YTLIB_MEMCHECK
61#define ytIntArray_new() ytIntArray_newm(__FILE__,__LINE__)
62ytIntArray * ytIntArray_newm(const char * file, int line);
63#else
64ytIntArray * ytIntArray_new();
65#endif
66void ytIntArray_delete(ytIntArray * this);
67void ytIntArray_deletev(void * this);
68void ytIntArray_deleteAll(ytIntArray * this);
69void ytIntArray_deleteAllv(void * this);
70ytIntArray * ytIntArray_clone(const ytIntArray * this);
71ytObject * ytIntArray_cloneI(const ytObject * this);
72ytIntArray * ytIntArray_arrayNew(size_t size);
73void ytIntArray_arrayDelete(ytIntArray * this, size_t size);
74void ytIntArray_dump(const ytIntArray * this, FILE * fp);
75void ytIntArray_dumpv(const ytObject * this, FILE * fp);
76size_t ytIntArray_size(const ytIntArray * this);
77size_t ytIntArray_buffSize(const ytIntArray * this);
78size_t ytIntArray_memSize(const ytIntArray * this);
79size_t ytIntArray_arrayMemSize(const ytIntArray * this, size_t n);
80void ytIntArray_clear(ytIntArray * this);
81ytIntArray * ytIntArray_setBuffSize(ytIntArray * this, size_t new_size);
82void ytIntArray_add(ytIntArray * this, int value);
83void ytIntArray_addIntArray(ytIntArray * this, const ytIntArray * values);
84void ytIntArray_set(ytIntArray * this, size_t index, int value);
85void ytIntArray_setSize(ytIntArray * this, size_t size);
86void ytIntArray_insert(ytIntArray * this, size_t index, int value);
87int ytIntArray_remove(ytIntArray * this, size_t index);
88void ytIntArray_copy(ytIntArray * this, const ytIntArray * src);
89void ytIntArray_copyArray(ytIntArray * this, size_t index, const int * array, size_t size);
90int ytIntArray_get(const ytIntArray * this, size_t index);
91int ytIntArray_pop(ytIntArray * this);
92int * ytIntArray_ptr(ytIntArray * this);
93void ytIntArray_sort(ytIntArray * this);
94size_t ytIntArray_find(const ytIntArray * this, const int v);
95void ytIntArray_print(const ytIntArray * this, FILE * fp, char * delim);
96int ytIntArray_sprint(const ytIntArray * this, char * buff, size_t size, char * delim);
97ytObject * ytIntArray_obj(ytIntArray * this);
98ytObject * ytIntArray_pObj(ytIntArray ** ptr);
99ytIntArray * ytIntArray_from(ytObject * this);
100ytIntArray ** ytIntArray_objP(ytObject * this);
101size_t ytIntArray_memorySize(const ytIntArray * this);
102size_t ytIntArray_memorySizeI(const ytObject * this);
103ytByte * ytIntArray_serializeI(const ytObject * obj, ytByte ** pptr);
104ytByte * ytIntArray_serialize(const ytIntArray * this, ytByte ** pptr);
105ytIntArray * ytIntArray_deserialize(ytByte ** const pptr);
106ytObject * ytIntArray_deserializeI(ytByte ** const ptr);
107#ifdef USE_MPI
108#include <mpi.h>
109void ytIntArray_MPI_Bcast(ytIntArray ** pObj, int root, MPI_Comm comm);
110void ytIntArray_MPI_BcastI(ytObject ** pObject, int root, MPI_Comm comm);
111#endif
112
113#endif /* __YTLIB_INT_ARRAY_H */
Expandable array.
The basis class.