Use a Set, a Map, or combination of the two. In this case, a simple Map keyed with GroupNum and valued with a Set (filled with IDs) would work.