Skip to content

hashset_iterator: skipping over index 0 #13

Description

@juicyslew

In the Hashset itr code here:

hashset_itr_t hashset_iterator(hashset_t set)
{
  hashset_itr_t itr = calloc(1, sizeof(struct hashset_itr_st));
  if (itr == NULL)
    return NULL;

  itr->set = set;
  itr->index = 0;

  /* advance to the first item if one is present */
  if (set->nitems > 0)
    hashset_iterator_next(itr);
  return itr;
}

On trying to use this code to iterate through my hashset, every so often an item would go to index 0 in the set. The code below would promptly be skipped over by the code below. I'm not sure what the goal this code was, but if there isn't any outstanding reason for it, it should probably be removed!

if (set->nitems > 0)
    hashset_iterator_next(itr);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions