Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/vis12/src/include/Diderot/dyn-seq.h
ViewVC logotype

Diff of /branches/vis12/src/include/Diderot/dyn-seq.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1713, Fri Mar 9 21:37:19 2012 UTC revision 1714, Sat Mar 10 00:00:50 2012 UTC
# Line 13  Line 13 
13    
14  typedef struct {  typedef struct {
15      unsigned int base;      unsigned int base;
16      size_t      nElems;      size_t      nElems;         //!< number of elements in the sequence
17      size_t      size;      size_t      size;           //!< size of data buffer in elements
18      void        *data;      void        *data;          //!< pointer to underlying data buffer
19  } Diderot_DynSeq_t;  } Diderot_DynSeq_t;
20    
21  #define DYNSEQ_SUB(ty, seq, i)  (*((ty *)Diderot_DynSeqAddr(sizeof(ty), seq, i)))  #define DYNSEQ_SUB(ty, seq, i)  (*((ty *)Diderot_DynSeqAddr(sizeof(ty), seq, i)))
22  #define DYNSEQ_MK(ty, n, data)  Diderot_DynSeqMk(sizeof(ty), n, data)  #define DYNSEQ_MK(ty, n, data)  Diderot_DynSeqMk(sizeof(ty), n, data)
23    
24    inline unsigned int Diderot_DynSeqLength (Diderot_DynSeq_t *seq)
25    {
26        return seq->nElems;
27    }
28    
29  inline Diderot_DynSeq_t *Diderot_DynSeqAlloc (size_t elemSz, int initialSz)  inline Diderot_DynSeq_t *Diderot_DynSeqAlloc (size_t elemSz, int initialSz)
30  {  {
31      Diderot_DynSeq_t *seq = NEW(Diderot_DynSeq_t);      Diderot_DynSeq_t *seq = NEW(Diderot_DynSeq_t);
# Line 50  Line 55 
55      return ((char *)(seq->data) + elemSz * i);      return ((char *)(seq->data) + elemSz * i);
56  }  }
57    
58    //! append an element to a sequence
59  Diderot_DynSeq_t *Diderot_DynSeqAppend (size_t elemSz, Diderot_DynSeq_t *, void *);  Diderot_DynSeq_t *Diderot_DynSeqAppend (size_t elemSz, Diderot_DynSeq_t *, void *);
60    
61    //! prepend an element to a sequence
62  Diderot_DynSeq_t *Diderot_DynSeqPrepend (size_t elemSz, void *, Diderot_DynSeq_t *);  Diderot_DynSeq_t *Diderot_DynSeqPrepend (size_t elemSz, void *, Diderot_DynSeq_t *);
63    
64    //! concatenate two sequences
65  Diderot_DynSeq_t *Diderot_DynSeqConcat (size_t elemSz, Diderot_DynSeq_t *, Diderot_DynSeq_t *);  Diderot_DynSeq_t *Diderot_DynSeqConcat (size_t elemSz, Diderot_DynSeq_t *, Diderot_DynSeq_t *);
66    
67    //! \brief copy the elements of a sequence to an array
68    //! \param elemSz the size of the sequence elements in bytes
69    //! \param dst the destination array
70    //! \param seq the source sequence
71    //! \return the address of the element that follows the array
72    void *Diderot_DynSeqCopy (size_t elemSz, void *dst, Diderot_DynSeq_t *seq);
73    
74  #endif /* !_DIDEROT_DYN_SEQ_H_ */  #endif /* !_DIDEROT_DYN_SEQ_H_ */

Legend:
Removed from v.1713  
changed lines
  Added in v.1714

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0