Skip to content

Instantly share code, notes, and snippets.

@mauricewyn
Created May 8, 2015 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mauricewyn/a809f1268520587e4a24 to your computer and use it in GitHub Desktop.
Save mauricewyn/a809f1268520587e4a24 to your computer and use it in GitHub Desktop.
CFSetForeach
#define CFSetForeach(type,element,set) \
for (typeof(type) element, \
*_foreach_set = (typeof(type)*)set, \
*_foreach_count = (typeof(type)*)(intptr_t)CFSetGetCount((CFSetRef)_foreach_set), \
*_foreach_cache[(intptr_t)_foreach_count + 1], \
*_foreach_index = (CFSetGetValues((CFSetRef)_foreach_set,(const void**)_foreach_cache), (typeof(type)*)(intptr_t)0); \
element = ((typeof(type)*)_foreach_cache)[(intptr_t)_foreach_index], ((intptr_t)_foreach_index < (intptr_t)_foreach_count); \
_foreach_index = (typeof(type)*)((intptr_t)_foreach_index + 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment