Skip to content
Permalink
Browse files

Added some linked-list interface methods for segments.

Signed-off-by: unknown <saq10002@iteb-219.ad.engr.uconn.edu>
  • Loading branch information...
unknown
unknown committed Oct 8, 2014
1 parent b5fa1b2 commit 983c59ddf17ae95ed75120d2f8e0cc5b93e10a0b
Showing with 36 additions and 0 deletions.
  1. +36 −0 dynarrc/dynarrc.interface.h
@@ -25,3 +25,39 @@
// segment at a particular index
// use segNull() to check validity of the returned segment
#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.
You can’t perform that action at this time.