Design is all about answering questions and coming up with new questions when the first are answered.
Are the group IDs sequential? Is the set of groups dynamic--will groups be added and subtracted during the run of the program?
If the groups are sequential and relatively static, you might want to just use a vector to contain them. They have fast lookup and don't take up a lot of excess space.
If the group IDs are more arbitrary, you probably need a map or a hash. Since you will only have 100 or so groups, the lookup time in a map shouldn't be noticeably greater than for a hash, so I might recommend that structure.
Depending on how you plan to use the members of the groups, the groups could be sets or maps themselves. If you plan to look up specific IP addresses within a group, I would go with a map keyed by the IP Address. If you will just be iterating through each group, you could go with a set (to guarantee uniqueness) or even a list or vector if the input is can be trusted to be unique. Again, I don't really know how you plan to use the groups.
So, my two suggestions are (approximate code):
If you need to look up individual IP addresses:
1 2 3 4 5 6
|
typedef std::string IPAddress;
typedef int GroupID;
class IPAttributes{/* "other" attributes */};
typedef std::map<IPAddress, IPAttributes> IPGroup;
typedef std::map<GroupID, IPGroup> IPGroupMap;
|
If you do not need to look up individual IP Addresses:
1 2 3 4 5 6
|
typedef std::string IPAddress;
typedef int GroupID;
class IPAttributes{IPAddress addr; /* "other" attributes */};
typedef std::set<IPAttributes> IPGroup;
typedef std::map<GroupID, IPGroup> IPGroupMap;
|