### 7 releases

0.3.2 | May 3, 2018 |
---|---|

0.3.1 | May 3, 2018 |

0.2.2 | May 1, 2018 |

0.2.0 | Apr 30, 2018 |

0.1.0 | Apr 30, 2018 |

#**301** in Data structures

**125** downloads per month

**Apache-2.0/MIT**

39KB

543 lines

# subset-map

## Summary

is a map like data structure where the keys are combinations
of elements the `subset-map`

has been initialized with.`SubsetMap`

The order of the elements is defined by the position of an element
within the elements the

has been initialized with.`SubsetMap`

clones the elements into the subsets. So you should
consider to only use element types where you would feel good to assign
them the `SubsetMap`

trait.`Copy`

Lookup is done linearly. Therefore

should only be used
with not too big sets of elements.`SubsetMap`

### Example

`use` `subset_map``::``*``;`
`//` Initialize the map where the payloads are basically the keys
`let` subset_map `=` `SubsetMap``::`fill`(``&``[``1``,` `2``,` `3``]``,` `|``x``|` `x``.``iter``(``)``.``cloned``(``)``.``collect``::``<``Vec``<``_``>``>``(``)``)``;`
`assert_eq!``(`subset_map`.``get``(``&``[``1``]``)``,` `Some``(``&``vec!``[``1``]``)``)``;`
`assert_eq!``(`subset_map`.``get``(``&``[``2``]``)``,` `Some``(``&``vec!``[``2``]``)``)``;`
`assert_eq!``(`subset_map`.``get``(``&``[``3``]``)``,` `Some``(``&``vec!``[``3``]``)``)``;`
`assert_eq!``(`subset_map`.``get``(``&``[``1``,` `2``]``)``,` `Some``(``&``vec!``[``1``,` `2``]``)``)``;`
`assert_eq!``(`subset_map`.``get``(``&``[``2``,` `3``]``)``,` `Some``(``&``vec!``[``2``,` `3``]``)``)``;`
`assert_eq!``(`subset_map`.``get``(``&``[``1``,` `3``]``)``,` `Some``(``&``vec!``[``1``,` `3``]``)``)``;`
`assert_eq!``(`subset_map`.``get``(``&``[``1``,` `2``,` `3``]``)``,` `Some``(``&``vec!``[``1``,` `2``,` `3``]``)``)``;`
`//` No internal ordering is performed:
`//` The position in the original set is crucial:
`assert_eq!``(`subset_map`.``get``(``&``[``2``,``1``]``)``,` `None``)``;`

## Features

The

feature allows serialization and deserialization with `serde`

.`serde`

Recent Changes

- 0.3.2
- Added more methods to iterate/walk

- 0.3.1
- Added methods to work with payloads

- 0.3.0
- [BREAKING CHANGES]: Changed API to be more consistent

- 0.2.2
- fixed

function`size`

- fixed
- 0.2.1
- Optimized

and`find`

a bit`lookup` - Added

finction to return the number of combinations`size`

- Optimized
- 0.2.0
- Renamed MatchQuality to
`LookupResult`

also contains the no match case`LookupResult`- improved documentation

- Renamed MatchQuality to

## License

is distributed under the terms of both the MIT license and the Apache License (Version
2.0).`subset-map`

Copyright(2018) Christian Douven

See LICENSE-APACHE and LICENSE-MIT for details.

License: Apache-2.0/MIT