Comments (6)
Have you seen ListMultimap, from quiver?
https://github.com/google/quiver-dart/blob/master/lib/src/collection/multimap.dart
The plan is to have a Built version of it at some point. I think that would be a perfect fit for what you're doing?
from built_collection.dart.
Yes that looks useful. I guess from the outside ListMultiMap<String, Foo>
is pretty much the same as Map<String, List<Foo>>
but the internals are different?
from built_collection.dart.
It has a few additional useful methods on the interface, and, crucially, it handles creating empty lists for you. So once we have ListMultimapBuilder your code should simplify to:
var builder = new ListMultimapBuilder<String, Foo>();
for (Bar bar in bars) {
builder.add(bar.name, bar.foos);
}
from built_collection.dart.
Here is the pull request for BuiltListMultimap if you want to take a look before it goes in:
It'll be in some time next week, most likely.
from built_collection.dart.
Now published to pub. Please let us know if it works for you :)
from built_collection.dart.
Thanks for adding this! I ended up doing it in another way in the meantime. But I'm sure it will come in handy soon again. I'll let you know if I find any bugs when I use it :-).
from built_collection.dart.
Related Issues (20)
- Release for inference change HOT 1
- Add const BuiltList<T>.empty() HOT 6
- Add ListBuilder.indexOf HOT 1
- Allow BuiltList<T?> HOT 2
- BuiltList first & elementAt should be nullable HOT 3
- Custom serializer for BuiltMap HOT 1
- Tighten generics HOT 2
- Use `@checkResult` annotation
- Cannot rebuild a BuiltSet entry in BuiltMap HOT 7
- (Question) how to rebuild every value in BuiltList? HOT 1
- Why is the return operator[] on BuiltSetMultimap nullable?
- Docs for `asList` misleading
- Unable to update nested BuiltList inside ListBuilder HOT 5
- [Feature Request/ Question] Native Support for json_serializable / json_annotation HOT 3
- Found 1 file excluded from sound null safety HOT 1
- Shouldn't BuiltMap<String, BuiltSet<int>> work out of the box? HOT 9
- BuiltMap.containsKey should accept `Object?` HOT 1
- Built Collections deep comparison question HOT 3
- asList() always returns a new instance HOT 1
- tighten `MapBuilder` factory parameter HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from built_collection.dart.