Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields  

ToySegmentList.h

00001 /***************************************************************************
00002                           ToySegmentList.h
00003       A set of functions for creating, destroying, and
00004       manipulating doubly-linked lists of memory segments.
00005 
00006                              -------------------
00007     begin                : Sat Jan 25 2003
00008     copyright            : (C) 2003 by Tyler Montbriand
00009     student #            : 200200370
00010     class                : CS330
00011     email                : monttyle@heavyspace.ca 
00012 ***************************************************************************/
00013 #ifndef __TOYSEGLIST_H__
00014 #define __TOYSEGLIST_H__
00015 
00016 #ifdef __cplusplus
00017   extern "C" {
00018 #endif
00019 
00025 
00030 typedef struct SegList
00031 {
00033   struct ToySegment seg;
00035   struct SegList *prev;
00037   struct SegList *next;
00038 } SegList;
00039 
00040 /* ! \brief Convenience macro.  Returns the address of the last byte in the segment.*/
00041 #define SegEnd(x) ((x)->pos + (x)->len)
00042 
00044 int TMM_SegListSize(SegList *list);
00045 
00047 SegList *TMM_OrderedInsert(SegList *list, SegList *node);
00048 
00050 void TMM_RemoveFromList(SegList *node);
00051 
00053 SegList *TMM_CopySegList(SegList *list);
00054 
00056 SegList *TMM_CreateSegList(int pos, int len, SegList *prev, SegList *next);
00057 
00059 SegList *TMM_SeekSegListHead(SegList *list);
00061 SegList *TMM_SeekSegListEnd(SegList *list);
00062 
00064 SegList *TMM_AppendSegList(SegList *list, SegList *node);
00065 
00067 int TMM_FreeSegList(SegList *list);
00068 
00070 int TMM_CompSegList(const SegList *l1, const SegList *l2);
00071 
00073 SegList *TMM_SortSegList(SegList *list);
00074 
00076 SegList *TMM_RemoveAreaFromSegList(SegList *list, int pos, int len);
00077 
00079 SegList *TMM_MergeSegList(SegList *list);
00080 
00081 
00083 int TMM_AreaIntersectsSeg(ToySegment *seg1, ToySegment *seg2);
00084 
00086 SegList *TMM_AddAreaToSegList(SegList *list, int pos, int len);
00087 
00089 void TMM_PrintSegList(SegList *list);
00090 
00097 int TMM_SubtractSegs(ToySegment *seg1, ToySegment *seg2, ToySegment segOut[2]);
00098 
00100 int TMM_FindSegSpace(SegList *list, int n);
00101 
00104 #ifdef __cplusplus
00105   }
00106 #endif
00107 
00108 #endif/*__TOYSEGLIST_H__*/

Generated on Fri Apr 4 14:29:07 2003 for ToyMem by doxygen1.3-rc3