(Feature suggestion) SortedMultiSet

Đang mở
#779 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
30/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
julia
Lĩnh vực
data

Hướng nghiên cứu

Bắt đầu bằng cách xem xét các triển khai SortedSet và SortedMultiDict hiện có cùng các API của chúng. Xác định SortedMultiSet nên xử lý các khóa so sánh trùng lặp, việc chèn/xóa/tìm kiếm hiệu quả và việc xóa theo giá trị như thế nào; issue không xác định các tệp hoặc bài kiểm thử, vì vậy cần có sự thống nhất với maintainer về tiêu chí hoàn thành.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

I think that this package is missing a SortedMultiSet type. As an example, let's say we want to collect a list of persons, sorted by age, as stored in an ages dictionary:

ages = Dict(:bob => 1, :sam => 2, :joe => 1)

and perform efficient insertions/deletions and searching on this list. My first reflex is using a SortedSet for this; however: SortedSet(keys(ages), Base.Order.By(x->ages[x])) merges the keys :bob: and :joe. (*)

There are two ways to work around this limitation right now:

  1. SortedSet((age, person) for (person, age) in ages);
  2. SortedMultiDict(age => person for (person, age) in ages).

However, both of them are somewhat memory-inefficient (they store information equivalent to a full copy of the ages database, as well as quite cumbersome to use (neither implementation allows a simple delete!(set, :bob) call). The second inconvenient may be fixed by writing a simple wrapper over either type (possibly the SortedMultiDict, which is somewhat more efficient), but the first one cannot be fixed except by writing a new structure.

(Also, keep in mind that the example I gave here is of course much simplified. In particular, the comparison values are numbers, and thus quite compact in memory. There could probably be some use cases where the comparison keys are big data structures, hence the fact that we don't want to copy all of them).

(*) in my view this is simply a bad design choice in the definition of SortedSet, because only equal values should be merged, i.e. a set should be allowed to be sorted according to a preorder, but it is likely much too late to change this.

Ngôn ngữ chính
Julia
Star
747
Fork
261
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của JuliaCollections/DataStructures.jl

Tất cả issue của JuliaCollections/DataStructures.jl

Issue tương tự

Thêm issue về Julia

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.