// an indexing structure for grayscale images // -all images have the same size // -images are sorted by // 1. average brightness // 2. "lexical" scanline ordering (within same brightness) // -every image can have an arbitrary value associated (type "A") sclass ScaledGrayscaleCache extends Meta is WidthAndHeight { int w, h; new TreeSet entries; class Entry is Comparable { double brightness; BWImage image; A value; public int compareTo(Entry e) { if (brightness != e.brightness) ret cmp(brightness, e.brightness); ret compareBWImagesByScanlineOrdering(image, e.image); } } *(int *w, int *h) {} public int getWidth() { ret w; } public int getHeight() { ret h; } }