Function ecs_filter_pivot_term


#include <include/flecs.h>

FLECS_API int32_t ecs_filter_pivot_term(const ecs_world_t *world, const ecs_filter_t *filter)


Get pivot term for filter. The pivot term is the term that matches the smallest set of tables, and is a good default starting point for a search.

The following conditions must be met for a term to be considered as pivot:

  • It must have a This subject
  • It must have the And operator

When a filter does not have any terms that match those conditions, it will return -1.

If one or more terms in the filter have no matching tables the filter won't yield any results. In this case the operation will return -2 which gives a search function the option to early out.


world - The world.

filter - The filter.

Index of the pivot term (use with filter->terms)


Line 3222 in include/flecs.h.