Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added some linked-list interface methods for segments.
Signed-off-by: unknown <saq10002@iteb-219.ad.engr.uconn.edu>
  • Loading branch information
unknown committed Oct 8, 2014
1 parent b5fa1b2 commit 983c59d
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions dynarrc/dynarrc.interface.h
Expand Up @@ -25,3 +25,39 @@
// segment at a particular index // segment at a particular index
// use segNull() to check validity of the returned segment // use segNull() to check validity of the returned segment
#define getSegAt(type, index) SEG_ARR_GET_SEG(type, index) #define getSegAt(type, index) SEG_ARR_GET_SEG(type, index)

//------- linked-list behavior ------

// returns the next segment
// use segNull() to check validity ofthe returned segment
#define getNextSeg(type, seg) SEG_ARR_GET_SEG(type, SEG_ARR_SEG_NEXT_INDEX(type, seg))
// checks whether the next segment exists
#define hasNext(type, seg) ((seg).nextIndex != EMPTY_INDEX)
// sets the next segment
// this is a ``hard`` action, because it
// modifies the segment in the data structure
#define setNextSeg(type, seg, nextSeg) \
( seg.nextIndex = \
(PTR_SEG_FROM_INDEX(type, (seg).index)->nextIndex) = \
nextSeg.index)

#define getSegData(seg) (\
(seg).data = \
(PTR_SEG_FROM_INDEX(type, (seg).index)->data)\
)

#define setSegData(type, seg, data) \
( (seg).data = \
(PTR_SEG_FROM_INDEX(type, (seg).index)->data) = \
(data))
// marks the segment as NULL/empty
// this is a ``soft`` action, because it
// does not modify/delete the segment in the data structure
#define makeSegNull(seg) do{(seg).index = EMPTY_INDEX;}while(0)
// marks the segment as NULL/empty
// this is a ``hard`` action, because it
// modifies the segment in the data structure
#define makeNextNull(type, seg) do{\
(seg).nextIndex = \
PTR_SEG_FROM_INDEX(type, (seg).index)->nextIndex) = EMPTY_INDEX;\
}while(0)

0 comments on commit 983c59d

Please sign in to comment.