/* Whenever a new object with this struct is created, all fields have
to be set to NULL */
+/**
+ * \addtogroup XBT_swag
+ *
+ * Warning, this module is done to be efficient and performs tons of
+ * cast and dirty things. So avoid using it unless you really know
+ * what you are doing. It is basically a fifo but with restrictions so that
+ * it can be used as a set. Any operation (add, remove, belongs) is O(1) and
+ * no call to malloc/free is done.
+ *
+ * @{
+ */
+
/** \name Swag types
- \ingroup XBT_swag
Specific set.
/**< A typical swag */
/* @} */
+/** \name Functions
+ */
+/* @{ */
+
xbt_swag_t xbt_swag_new(size_t offset);
void xbt_swag_free(xbt_swag_t swag);
void xbt_swag_init(xbt_swag_t swag, size_t offset);
#define xbt_swag_getNext(obj,offset) (((xbt_swag_hookup_t)(((char *) (obj)) + (offset)))->prev)
#define xbt_swag_getPrev(obj,offset) (((xbt_swag_hookup_t)(((char *) (obj)) + (offset)))->next)
-/**
- * \ingroup XBT_swag
+/**
* \brief Offset computation
* \arg var a variable of type <tt>struct</tt> something
* \arg field a field of <tt>struct</tt> something
* Because it is portable...
*/
#define xbt_swag_offset(var,field) ((char *)&( (var).field ) - (char *)&(var))
+/* @} */
/**
- \name Swag iterator
- \ingroup XBT_swag
+ * \name Swag iterator
*
* Iterates over the whole swag.
- */
-/* @{ */
+ *
+ * @{ */
+
+ /** @brief A simple swag iterator
+ * @param obj the indice of the loop
+ * @param swag what to iterate over
+ * @warning you cannot modify the \a swag while using this loop
+ * @hideinitializer */
#define xbt_swag_foreach(obj,swag) \
for((obj)=xbt_swag_getFirst((swag)); \
(obj)!=NULL; \
(obj)=xbt_swag_getNext((obj),(swag)->offset))
-/**< A simple swag iterator
- * \param obj the indice of the loop
- * \param swag what to iterate over
- \warning you cannot modify the \a swag while using this loop */
+/**
+ * @brief A safe swag iterator
+ * @param obj the indice of the loop
+ * @param obj_next the object that is right after (if any) \a obj in the swag
+ * @param swag what to iterate over
+ * @hideinitializer
+
+ You can safely modify the \a swag while using this loop.
+ Well, safely... Err. You can remove \a obj without having any
+ trouble at least. */
+
#define xbt_swag_foreach_safe(obj,obj_next,swag) \
for((obj)=xbt_swag_getFirst((swag)), \
((obj)?(obj_next=xbt_swag_getNext((obj),(swag)->offset)): \
(obj)=obj_next, \
((obj)?(obj_next=xbt_swag_getNext((obj),(swag)->offset)): \
(obj_next=NULL)) )
-/**< A safe swag iterator
- * \param obj the indice of the loop
- * \param obj_next the object that is right after (if any) \a obj in the swag
- * \param swag what to iterate over
-
- You can safely modify the \a swag while using this loop.
- Well, safely... Err. You can remove \a obj without having any
- trouble at least. */
+/* @} */
/* @} */
#endif /* _XBT_SWAG_H */