00001 00015 /* 00016 * Copyright 2003, 2004 Ian Searle. All rights reserved. 00017 * 00018 * Redistribution and use in source and binary forms, with or without 00019 * modification, are permitted provided that the following 00020 * conditions are met: 00021 * 00022 * 1: Redistributions of source code must retain the above 00023 * copyright notice, this list of conditions and the following 00024 * disclaimer. 00025 * 00026 * 2: Redistributions in binary form must reproduce the above 00027 * copyright notice, this list of conditions and the following 00028 * disclaimer in the documentation and/or other materials 00029 * provided with the distribution. 00030 * 00031 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 00032 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00033 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00034 * DISCLAIMED. IN NO EVENT SHALL IAN SEARLE OR CONTRIBUTORS 00035 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 00036 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00037 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00038 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00039 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00040 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00041 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00042 * DAMAGE. 00043 * 00044 */ 00045 00046 #ifndef _TUPLE_H 00047 #define _TUPLE_H 00048 00049 #include "segment.h" 00050 00052 typedef struct _tuple Tuple; 00053 00055 struct _tuple { 00056 Segment *seg; 00057 unsigned int ibegin; 00058 unsigned int iend; 00059 }; 00060 00061 00088 void tuple_Init(void *(*tuple_allocate)(size_t), void (*tuple_deallocate)(void *)); 00089 00105 Tuple *tuple_Create(Segment *seg, unsigned int ibegin, unsigned int iend); 00106 00121 void tuple_DeleteBorrowed(Tuple *tuple); 00122 00137 void tuple_DeleteOwned(Tuple *tuple); 00138 00149 Tuple *tuple_Copy(Tuple *tuple); 00150 00163 void tuple_Print(Tuple *tuple); 00164 00176 char *tuple_SegElPtr(Tuple *tuple, unsigned int index); 00177 00186 Segment *tuple_Seg(Tuple *tuple); 00187 00196 unsigned int tuple_Begin(Tuple *tuple); 00197 00206 unsigned int tuple_End(Tuple *tuple); 00207 00208 /* 00209 * \brief 00210 * Set the begin index of a tuple. 00211 * 00212 * \param tuple The input tuple to manipulate. 00213 * \param end The new begin value to set. 00214 * 00215 * \return 0 success 00216 * \return 1 failure: tuple pointer invalid value (null) 00217 * \return 2 failure: begin > tuple_End(tuple) 00218 */ 00219 unsigned int tuple_SetBegin(Tuple *tuple, unsigned int begin); 00220 00221 /* 00222 * \brief 00223 * Set the end index of a tuple. 00224 * 00225 * \param tuple The input tuple to manipulate. 00226 * \param end The new end value to set. 00227 * 00228 * \return 0 success 00229 * \return 1 failure: tuple pointer invalid value (null) 00230 * \return 2 failure: end >= tuple_Length() 00231 * \return 3 failure: end < tuple_Begin(tuple) 00232 */ 00233 unsigned int tuple_SetEnd(Tuple *tuple, unsigned int end); 00234 00243 unsigned int tuple_Length(Tuple *tuple); 00244 00268 unsigned int tuple_ShiftBegin(Tuple *tuple, unsigned int N); 00269 00283 unsigned int tuple_ShiftEnd(Tuple *tuple, unsigned int N); 00284 00285 #endif /* _TUPLE_H */