// A = the objects to be cached (each associated with a BWImage // which is scaled down to the thumbnail size.) sclass G22ThumbnailCache extends Meta is WidthAndHeight { int w, h; int bitsPerPixel, bitsPerImage; new MultiMap elementsByThumbnail; *(int *w, int *h, int *bitsPerPixel) { bitsPerImage = safeMul(w, h, bitsPerPixel); if (bitsPerImage >= 64) fail("Too many bits per thumbnail (64 allowed max)", +w, +h, +bitsPerPixel, +bitsPerImage); } public int getWidth() { ret w; } public int getHeight() { ret h; } void add(A element, IBWIntegralImage image) { long thumbnail = getThumbnail(image); elementsByCacheImage.add(thumbnail, element); } long getThumbnail(IBWIntegralImage image) { bitsPerImage } }