Example #1
0
/** @brief Creator
 *  @param dict the dict
 */
XBT_INLINE xbt_dict_cursor_t xbt_dict_cursor_new(const xbt_dict_t dict)
{
  xbt_dict_cursor_t res = NULL;

  res = xbt_new(s_xbt_dict_cursor_t, 1);
  res->dict = dict;

  xbt_dict_cursor_rewind(res);

  return res;
}
Example #2
0
/**
 * @brief Create the cursor if it does not exists. Rewind it in any case.
 *
 * @param      dict   on what to let the cursor iterate
 * @param[out] cursor dest address
 */
inline void xbt_dict_cursor_first(const xbt_dict_t dict, xbt_dict_cursor_t * cursor)
{
  XBT_CDEBUG(xbt_dict_cursor, "xbt_dict_cursor_first");
  if (!*cursor) {
    XBT_CDEBUG(xbt_dict_cursor, "Create the cursor on first use");
    *cursor = xbt_dict_cursor_new(dict);
  } else {
    xbt_dict_cursor_rewind(*cursor);
  }
  if (dict != NULL && (*cursor)->current == NULL) {
    xbt_dict_cursor_step(*cursor);      /* find the first element */
  }
}