Ejemplo n.º 1
0
void testApplyFunc() {
    int vals[] = {1,2,3,4,5};
    linked_list* list = initLinkedList();
    for (int i = 0; i < sizeof(vals) / sizeof(vals[0]); i++) {
        addToTail(list, &(vals[i]));
    }
    printf("Should see :\n");
    for (int i = 0; i < sizeof(vals) / sizeof(vals[0]); i++) {
        printf("%d, ", vals[i]);
    }
    printf("\nActual:\n");
    applyFunc(list, intPrinter);
    printf("\n");
    freeLinkedList(list);
}
Ejemplo n.º 2
0
sk_sp<T> SkColorSpaceXformer::cachedApply(const T* src, Cache<T>* cache,
                                          sk_sp<T> (*applyFunc)(const T*, SkColorSpaceXformer*)) {
    if (!src) {
        return nullptr;
    }

    auto key = sk_ref_sp(const_cast<T*>(src));
    if (auto* xformed = cache->find(key)) {
        return sk_ref_sp(xformed->get());
    }

    auto xformed = applyFunc(src, this);
    cache->set(std::move(key), xformed);

    return xformed;
}