Is there an efficient persistent index data structure with multiple indexes

I am looking for an efficient indexed persistent data structure. I usually work in .NET and I know about FSharp Map, however this implementation and most of the others that I know about provide only one “index”, the left side of the display.

Basically a script here

public class MyObject
    public int Id { get; }
    public int GroupId { get; }
    public string Name { get; }

If the object identifier will be a globally unique set of added elements. GroupId can have duplicate values, and I want to be able to query all the values ​​using the corresponding GroupId, and within the GroupId names will be unique, but can be duplicated in different GroupId. This is not a situation where I can simply create a composite key of three fields, because I need independent access to groups of elements based on certain field values.

I can do this and in the past use dictionaries of dictionaries that were recommended in other posts here in STackoverflow ... however I also want the data structure to be 1) Completely persistent and all that means 2) memory efficiency - that means that versions should have as many nodes as possible 3) effective in modifications - I would like it to be fast

I understand that I ask very little here, but I wanted to ask to avoid even trying to reinvent the wheel, if it has already been done.

thanks

+3
source share
3 answers

, , . Imbricating ( , , ,...) , ( , Index1, , Index2), .

, , , , , , . , , . . .

, , , , . . . , .

+2

, , , , , F # , , ,

Map<int, Map<string, MyObject> >  // int is groupid, string is name

? , id.

Clojure; Clojure, , -, Clojure.

0

, FP-.

, ?

, , , .

If you need quick access to a group, you can have a list map so you can pull out all the objects in the group.

There are different data structures and many functions that work on each, but you should first think about your problem from a functional rather than an object-oriented POV.

0
source

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


All Articles