Ejemplo n.º 1
0
static void *GetPrevious(Iterator *it)
{
    struct DequeIterator *li = (struct DequeIterator *)it;
    Deque *L = li->D;
    DequeNode rvp;
    size_t i;

    if (li->index >= L->count || li->index == 0)
    	return NULL;
    if (li->timestamp != L->timestamp) {
    	L->RaiseError("GetNext",CONTAINER_ERROR_OBJECT_CHANGED);
    	return NULL;
    }
    rvp = L->head;
    i=0;
    li->index--;
    if (li->index > 0) {
    	while (rvp != NULL && i < li->index) {
    		rvp = rvp->Next;
    		i++;
    	}
    }
    if (rvp == NULL) return NULL;
    li->Current = rvp;
    return rvp->Data;
}
Ejemplo n.º 2
0
static void *GetFirst(Iterator *it)
{
    struct DequeIterator *li = (struct DequeIterator *)it;
    Deque *L = li->D;
    if (L->count == 0)
    	return NULL;
    if (li->timestamp != L->timestamp) {
    	L->RaiseError("GetNext",CONTAINER_ERROR_OBJECT_CHANGED);
    	return NULL;
    }
    li->index = 0;
    li->Current = L->head;
    return L->head->Data;
}
Ejemplo n.º 3
0
static void *GetNext(Iterator *it)
{
    struct DequeIterator *li = (struct DequeIterator *)it;
    Deque *D = li->D;
    void *result;

    if (li->index >= (D->count-1) || li->Current == NULL)
    	return NULL;
    if (li->timestamp != D->timestamp) {
    	D->RaiseError("GetNext",CONTAINER_ERROR_OBJECT_CHANGED);
    	return NULL;
    }
    li->Current = li->Current->Next;
    li->index++;
    result = li->Current->Data;
    return result;
}