| 1 |
/* |
| 2 |
* IntGroup.h |
| 3 |
* |
| 4 |
* Created by Toshi Nagata on Sun Jun 17 2001. |
| 5 |
|
| 6 |
Copyright (c) 2000-2016 Toshi Nagata. All rights reserved. |
| 7 |
|
| 8 |
This program is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation version 2 of the License. |
| 11 |
|
| 12 |
This program is distributed in the hope that it will be useful, |
| 13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU General Public License for more details. |
| 16 |
*/ |
| 17 |
|
| 18 |
#ifndef __IntGroup_h__ |
| 19 |
#define __IntGroup_h__ |
| 20 |
|
| 21 |
typedef struct IntGroup IntGroup; |
| 22 |
typedef struct IntGroupIterator IntGroupIterator; |
| 23 |
|
| 24 |
struct IntGroupIterator { |
| 25 |
int refCount; |
| 26 |
IntGroup * intGroup; |
| 27 |
int index; |
| 28 |
int position; |
| 29 |
}; |
| 30 |
|
| 31 |
typedef int IntGroupStatus; |
| 32 |
enum { |
| 33 |
kIntGroupStatusNoError = 0, |
| 34 |
kIntGroupStatusOutOfMemory, |
| 35 |
kIntGroupStatusOutOfRange |
| 36 |
}; |
| 37 |
|
| 38 |
#ifdef __cplusplus |
| 39 |
extern "C" { |
| 40 |
#endif |
| 41 |
|
| 42 |
/* ------------------------------------------------------------------- |
| 43 |
IntGroup functions |
| 44 |
------------------------------------------------------------------- */ |
| 45 |
|
| 46 |
/* ��������� IntGroupRecord ������������������������������������������������������ NULL ������������ */ |
| 47 |
IntGroup * IntGroupNew(void); |
| 48 |
|
| 49 |
/* Initialize a new IntGroupRecord that has been statically allocated */ |
| 50 |
IntGroupIterator *IntGroupIteratorInit(IntGroup *psRef, IntGroupIterator *piRef); |
| 51 |
|
| 52 |
/* Allocate a new IntGroup, with points specified by arguments |
| 53 |
(start, length, start, length, etc...). Arguments end when start < 0. */ |
| 54 |
IntGroup * IntGroupNewWithPoints(int start, ...); |
| 55 |
|
| 56 |
/* Duplicate an existing IntGroup */ |
| 57 |
IntGroup *IntGroupNewFromIntGroup(const IntGroup *src); |
| 58 |
|
| 59 |
/* IntGroup ��� retain/release��� */ |
| 60 |
void IntGroupRetain(IntGroup *psRef); |
| 61 |
void IntGroupRelease(IntGroup *psRef); |
| 62 |
|
| 63 |
/* ��������������������������������������������������� */ |
| 64 |
void IntGroupClear(IntGroup *psRef); |
| 65 |
|
| 66 |
IntGroupStatus IntGroupCopy(IntGroup *psRef1, const IntGroup *psRef2); |
| 67 |
|
| 68 |
/* inStart ��������������� inCount ������������������������������������������������������������ */ |
| 69 |
IntGroupStatus IntGroupAdd(IntGroup *psRef, int inStart, int inCount); |
| 70 |
IntGroupStatus IntGroupRemove(IntGroup *psRef, int inStart, int inCount); |
| 71 |
IntGroupStatus IntGroupReverse(IntGroup *psRef, int inStart, int inCount); |
| 72 |
|
| 73 |
IntGroupStatus IntGroupAddIntGroup(IntGroup *psRef1, const IntGroup *psRef2); |
| 74 |
IntGroupStatus IntGroupRemoveIntGroup(IntGroup *psRef1, const IntGroup *psRef2); |
| 75 |
IntGroupStatus IntGroupReverseIntGroup(IntGroup *psRef1, const IntGroup *psRef2); |
| 76 |
|
| 77 |
/* inPoint ������������������������������������������ non-zero, ��������������������������� zero ������������ |
| 78 |
outIndex ��� NULL ������������������*outIndex ��������������������������������������������������������������� */ |
| 79 |
int IntGroupLookup(const IntGroup *psRef, int inPoint, int *outIndex); |
| 80 |
|
| 81 |
int IntGroupIsEqual(const IntGroup *psRef1, const IntGroup *psRef2); |
| 82 |
|
| 83 |
/* ������������������������������ */ |
| 84 |
int IntGroupGetCount(const IntGroup *psRef); |
| 85 |
|
| 86 |
/* ��������������������������������� */ |
| 87 |
int IntGroupGetIntervalCount(const IntGroup *psRef); |
| 88 |
|
| 89 |
/* inIndex ������������������������������������������������������������������inIndex ������������������ |
| 90 |
��������������������� -1 ������������ */ |
| 91 |
int IntGroupGetStartPoint(const IntGroup *psRef, int inIndex); |
| 92 |
|
| 93 |
/* inIndex ��������������������������������������������������������������������������������������������������������������������� |
| 94 |
inIndex ��������������������������������������� -1 ������������ */ |
| 95 |
int IntGroupGetEndPoint(const IntGroup *psRef, int inIndex); |
| 96 |
|
| 97 |
/* inIndex ���������������������������������������������������������������inIndex ������������������ |
| 98 |
��������������������� -1 ������������ */ |
| 99 |
int IntGroupGetInterval(const IntGroup *psRef, int inIndex); |
| 100 |
|
| 101 |
/* inCount ������������������������������������������������������������������ -1 ������������ */ |
| 102 |
int IntGroupGetNthPoint(const IntGroup *psRef, int inCount); |
| 103 |
|
| 104 |
/* inPoint ���������������������������������������������������������������������������������������������������-1������������ */ |
| 105 |
int IntGroupLookupPoint(const IntGroup *psRef, int inPoint); |
| 106 |
|
| 107 |
/* ������������ */ |
| 108 |
IntGroupStatus IntGroupUnion(const IntGroup *psRef1, const IntGroup *psRef2, IntGroup *psRef3); |
| 109 |
IntGroupStatus IntGroupIntersect(const IntGroup *psRef1, const IntGroup *psRef2, IntGroup *psRef3); |
| 110 |
IntGroupStatus IntGroupXor(const IntGroup *psRef1, const IntGroup *psRef2, IntGroup *psRef3); |
| 111 |
IntGroupStatus IntGroupConvolute(const IntGroup *psRef1, const IntGroup *psRef2, IntGroup *psRef3); |
| 112 |
IntGroupStatus IntGroupDeconvolute(const IntGroup *psRef1, const IntGroup *psRef2, IntGroup *psRef3); |
| 113 |
IntGroupStatus IntGroupDifference(const IntGroup *psRef1, const IntGroup *psRef2, IntGroup *psRef3); |
| 114 |
|
| 115 |
/* ������ */ |
| 116 |
IntGroupStatus IntGroupNegate(const IntGroup *psRef1, IntGroup *psRef2); |
| 117 |
|
| 118 |
/* Add offset to all points */ |
| 119 |
IntGroupStatus IntGroupOffset(IntGroup *psRef, int offset); |
| 120 |
|
| 121 |
/* Minimum and maximum number included in this group */ |
| 122 |
int IntGroupMinimum(const IntGroup *psRef); |
| 123 |
int IntGroupMaximum(const IntGroup *psRef); |
| 124 |
|
| 125 |
/* Debug */ |
| 126 |
char *IntGroupInspect(const IntGroup *pset); |
| 127 |
void IntGroupDump(const IntGroup *pset); |
| 128 |
|
| 129 |
/* Iterator support */ |
| 130 |
IntGroupIterator *IntGroupIteratorNew(IntGroup *psRef); |
| 131 |
IntGroupIterator *IntGroupIteratorInit(IntGroup *psRef, IntGroupIterator *piRef); |
| 132 |
void IntGroupIteratorRetain(IntGroupIterator *piRef); |
| 133 |
void IntGroupIteratorRelease(IntGroupIterator *piRef); |
| 134 |
void IntGroupIteratorReset(IntGroupIterator *piRef); |
| 135 |
void IntGroupIteratorResetAtLast(IntGroupIterator *piRef); |
| 136 |
int IntGroupIteratorNext(IntGroupIterator *piRef); |
| 137 |
int IntGroupIteratorLast(IntGroupIterator *piRef); |
| 138 |
|
| 139 |
#ifdef __cplusplus |
| 140 |
} |
| 141 |
#endif |
| 142 |
|
| 143 |
#endif /* __IntGroup_h__ */ |