EAPI Eina_Iterator * eina_inarray_iterator_reversed_new(const Eina_Inarray *array) { Eina_Iterator_Inarray *it; EINA_MAGIC_CHECK_INARRAY(array, NULL); eina_error_set(0); it = calloc(1, sizeof(Eina_Iterator_Inarray)); if (!it) { eina_error_set(EINA_ERROR_OUT_OF_MEMORY); return NULL; } EINA_MAGIC_SET(it, EINA_MAGIC_INARRAY_ITERATOR); EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR); it->array = array; it->pos = array->len; it->iterator.version = EINA_ITERATOR_VERSION; it->iterator.next = FUNC_ITERATOR_NEXT(_eina_inarray_iterator_prev); it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER (_eina_inarray_iterator_get_container); it->iterator.free = FUNC_ITERATOR_FREE(_eina_inarray_iterator_free); return &it->iterator; }
EAPI Eina_Iterator * eina_array_iterator_new(const Eina_Array *array) { Eina_Iterator_Array *it; EINA_SAFETY_ON_NULL_RETURN_VAL(array, NULL); EINA_MAGIC_CHECK_ARRAY(array); eina_error_set(0); it = calloc(1, sizeof (Eina_Iterator_Array)); if (!it) { eina_error_set(EINA_ERROR_OUT_OF_MEMORY); return NULL; } EINA_MAGIC_SET(it, EINA_MAGIC_ARRAY_ITERATOR); EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR); it->array = array; it->iterator.version = EINA_ITERATOR_VERSION; it->iterator.next = FUNC_ITERATOR_NEXT(eina_array_iterator_next); it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER( eina_array_iterator_get_container); it->iterator.free = FUNC_ITERATOR_FREE(eina_array_iterator_free); return &it->iterator; }
/** * @brief Returns a new iterator associated to @a list. * * @param list The list. * @return A new iterator. * * This function returns a newly allocated iterator associated to @p * list. If @p list is @c NULL or the count member of @p list is less * or equal than 0, this function still returns a valid iterator that * will always return false on eina_iterator_next(), thus keeping API * sane. * * If the memory can not be allocated, NULL is returned and * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is * returned. * * @warning if the list structure changes then the iterator becomes * invalid, and if you add or remove nodes iterator * behavior is undefined, and your program may crash! */ EAPI Eina_Iterator * eina_inlist_iterator_new(const Eina_Inlist *list) { Eina_Iterator_Inlist *it; eina_error_set(0); it = calloc(1, sizeof (Eina_Iterator_Inlist)); if (!it) { eina_error_set(EINA_ERROR_OUT_OF_MEMORY); return NULL; } it->head = list; it->current = list; it->iterator.version = EINA_ITERATOR_VERSION; it->iterator.next = FUNC_ITERATOR_NEXT(eina_inlist_iterator_next); it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER( eina_inlist_iterator_get_container); it->iterator.free = FUNC_ITERATOR_FREE(eina_inlist_iterator_free); EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR); return &it->iterator; }
EAPI Eina_Iterator * eina_inarray_iterator_new(const Eina_Inarray *array) { Eina_Iterator_Inarray *it; EINA_MAGIC_CHECK_INARRAY(array, NULL); it = calloc(1, sizeof(Eina_Iterator_Inarray)); if (!it) return NULL; EINA_MAGIC_SET(it, EINA_MAGIC_INARRAY_ITERATOR); EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR); it->array = array; it->iterator.version = EINA_ITERATOR_VERSION; it->iterator.next = FUNC_ITERATOR_NEXT(_eina_inarray_iterator_next); it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER (_eina_inarray_iterator_get_container); it->iterator.free = FUNC_ITERATOR_FREE(_eina_inarray_iterator_free); return &it->iterator; }
/** * Creates a new iterator over all matrix cells. * * Unlike eina_matrixsparse_iterator_new() this one will report all * matrix cells, even those that are still empty (holes). These will * be reported as dummy cells that contains no data. * * Be aware that iterating a big matrix (1000x1000) will call your * function that number of times (1000000 times in that case) even if * your matrix have no elements at all! * * The iterator data will be the cell reference, one may query current * position with eina_matrixsparse_cell_position_get() and cell value * with eina_matrixsparse_cell_data_get(). If cell is empty then the * reference will be a dummy/placeholder, thus setting value with * eina_matrixsparse_cell_data_set() will leave pointer unreferenced. * * @param m The Sparse Matrix reference, must @b not be @c NULL. * @return A new iterator. * * @warning if the matrix structure changes then the iterator becomes * invalid! That is, if you add or remove cells this iterator * behavior is undefined and your program may crash! */ EAPI Eina_Iterator * eina_matrixsparse_iterator_complete_new(const Eina_Matrixsparse *m) { Eina_Matrixsparse_Iterator_Complete *it; it = calloc(1, sizeof(*it)); if (!it) { eina_error_set(EINA_ERROR_OUT_OF_MEMORY); return NULL; } EINA_MAGIC_SET(it, EINA_MAGIC_MATRIXSPARSE_ITERATOR); EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR); it->m = m; it->idx.row = 0; it->idx.col = 0; it->ref.row = m->rows; it->ref.col = m->rows ? m->rows->cols : NULL; it->dummy.row.next = it->dummy.row.prev = NULL; it->dummy.row.cols = it->dummy.row.last_col = it->dummy.row.last_used = NULL; it->dummy.row.parent = (Eina_Matrixsparse *)m; EINA_MAGIC_SET(&it->dummy.row, EINA_MAGIC_MATRIXSPARSE_ROW); it->dummy.col.next = it->dummy.col.prev = NULL; it->dummy.col.data = NULL; it->dummy.col.parent = &it->dummy.row; EINA_MAGIC_SET(&it->dummy.col, EINA_MAGIC_MATRIXSPARSE_CELL); it->iterator.next = FUNC_ITERATOR_NEXT(_eina_matrixsparse_iterator_complete_next); it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eina_matrixsparse_iterator_complete_get_container); it->iterator.free = FUNC_ITERATOR_FREE(_eina_matrixsparse_iterator_complete_free); return &it->iterator; }
/** * Creates a new iterator over existing matrix cells. * * This is a cheap walk, it will just report existing cells and holes * in the sparse matrix will be ignored. That means the reported * indexes will not be sequential. * * The iterator data will be the cell reference, one may query current * position with eina_matrixsparse_cell_position_get() and cell value * with eina_matrixsparse_cell_data_get(). * * @param m The Sparse Matrix reference, must @b not be @c NULL. * @return A new iterator. * * @warning if the matrix structure changes then the iterator becomes * invalid! That is, if you add or remove cells this iterator * behavior is undefined and your program may crash! */ EAPI Eina_Iterator * eina_matrixsparse_iterator_new(const Eina_Matrixsparse *m) { Eina_Matrixsparse_Iterator *it; it = calloc(1, sizeof(*it)); if (!it) { eina_error_set(EINA_ERROR_OUT_OF_MEMORY); return NULL; } EINA_MAGIC_SET(it, EINA_MAGIC_MATRIXSPARSE_ITERATOR); EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR); it->m = m; it->ref.row = m->rows; it->ref.col = m->rows ? m->rows->cols : NULL; it->iterator.next = FUNC_ITERATOR_NEXT(_eina_matrixsparse_iterator_next); it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eina_matrixsparse_iterator_get_container); it->iterator.free = FUNC_ITERATOR_FREE(_eina_matrixsparse_iterator_free); return &it->iterator; }