Exemplo n.º 1
0
void
FillableVec::putEntries(unsigned numEntries,
                  const double* coefs,
                  const int* indices)
{
  for(unsigned i=0; i<numEntries; ++i) {
    putEntry(indices[i], coefs[i]);
  }
}
Exemplo n.º 2
0
/*
 * traverses linked list, calling userFunction on each element and freeing
 * node associated with element
 */
static void purge(LinkedList *ll, void (*userFunction)(void *element)) {
   LLNode *cur = ll->sentinel.next;

   while (cur != SENTINEL(ll)) {
      LLNode *next;
      if (userFunction != NULL)
         (*userFunction)(cur->element);
      next = cur->next;
      putEntry(ll, cur);
      cur = next;
   }
}
Exemplo n.º 3
0
int ll_removeLast(LinkedList *ll, void **element) {
   int status = 0;
   LLNode *p = SENTINEL(ll)->prev;

   if (p != SENTINEL(ll)) {
      status = 1;
      *element = p->element;
      unlink(p);
      putEntry(ll, p);
      ll->size--;
   }
   return status;
}
Exemplo n.º 4
0
static LLNode *getEntry(LinkedList *ll) {
   LLNode *p;

   if ((p = ll->freel) == NULL) {
      long i;
      for (i = 0; i < FL_INCREMENT; i++) {
         p = (LLNode *)malloc(sizeof(LLNode));
	 if (p == NULL)
            break;
         putEntry(ll, p);
      }
      p = ll->freel;
   }
   if (p != NULL)
      ll->freel = p->next;
   return p;
}
Exemplo n.º 5
0
int ll_remove(LinkedList *ll, long index, void **element) {
   int status = 0;

   if (index < ll->size) {
      long n;
      LLNode *p;

      status = 1;
      for (n = 0, p = SENTINEL(ll)->next; n < index; n++, p = p->next)
         ;
      *element = p->element;
      unlink(p);
      putEntry(ll, p);
      ll->size--;
   }
   return status;
}