// A is the user object associated with each mask (aka a "label") sclass G22HashedMasks { record noeq Mask(Image2B image) is IG22Mask { gettable new MultiSet labels; int hash; public int hashCode() { if (hash == 0) hash = (int) hashImage2B(image); ret hash; } public Image2B image() { ret image; } } new Map masks; void addRegion(IImageRegion region, A label) { var mask = new Mask(regionToMaskImage(region)); var existingMask = masks.get(mask.hashCode()); if (existingMask != null) mask = existingMask; else masks.put(mask.hashCode(), mask); mask.labels.add(label); ghost_cache = null; certainty_cache = null; labels.add(label); } L masks() { ret valuesList(masks); } !include early #1035854 // Masks holder Include }