Objective-C implementation of a histogram or bag data structure

Instead of implementing my own, I was interested to find out if anyone knows about the implementation of a histogram or batch data structure in Objective-C that I can use.

Essentially, a histogram is a hash list of lists in which lists contain values ​​related to their hash record. A good example is a bar chart of supermarket items, where you place each group of items of dairy products, meat, canned goods in their own bag. Then you can easily access each group of items according to their type.

+3
source share
4 answers

NSCountedSet is a multiset (aka "bag") that counts different objects but does not allow duplication. However, based on your explanation, I don’t think what you need, and there is no histogram that automatically values ​​based on many (usually numeric) ranges.

I believe that you really want a multimap , which is a key to one or more value relationship. Data structure structure I support CHMultiDictionary , a multiprocessor implementation. I will not require this to be perfect or complete, but I hope this can be useful for your problem.

+5

, . NSArrays NSDictionarys, :

NSMutableDictionary* dict = [NSMutableDictionary dictionary];
[dict setObject:[NSMutableArray arrayWithObjects:@"milk", @"eggs", @"cheese", nil] forKey:@"dairy"];
[dict setObject:[NSMutableArray arrayWithObjects:@"steak", @"sausages", @"mince", nil] forKey:@"meat"];

[[dict objectForKey:@"meat"] addObject:@"lamb"];

NSLog( @"Dictionary is %@", dict );
+3
+1

CFIOMultimap, -, . . nils , .

, .

0

Source: https://habr.com/ru/post/1710506/


All Articles