Ejemplo n.º 1
0
char *test_linked_list_find()
{
    struct ll_node *found = LL_find(head, val2);

    test_assert(found, "Did not find node");
    test_assert_streq(found->val, val2, "linked list found node has wrong val");

    found = LL_find(head, "herpderp");
    test_assert(found == NULL, "Found wrong node");

    return NULL;
}
Ejemplo n.º 2
0
//Does a linear search of the keyspace and returns a metadata struct or NULL
meta_t get_key_loc(cache_t cache, _key_t key)
{
  cache_real_obj *c = cache->cache;
  uint32_t bucket = hash(key) % c->num_buckets;
  node *current = LL_find(c->buckets[bucket], key);
  if (current == NULL) return NULL;
  return current->meta;
}
Ejemplo n.º 3
0
void LL_find_test(int count) {
    nodePtr head     = newTestLL(count),
            indexedN = LL_ofIndex(head, LL_length(head) / 2);

    LL_value_t indexedNValue = LL_findByValue(head, indexedN->value)->value;

    processTestResults("find: value in list",
            indexedNValue == indexedN->value);
    LL_free(&head, &indexedN);

    processTestResults("find: value not in list",
            LL_find(head, indexedN) == NULL);
    LL_freeAll(&head);
}