How to save a particular, mutable “order” into a database

后端 未结 9 1064
北恋
北恋 2021-02-05 03:34

Suppose I have some objects, and I want the user to be able to reorder them in any way they wish, say, by dragging them around. So I\'d have

  • Cheese
  • Muffin
9条回答
  •  眼角桃花
    2021-02-05 04:06

    Theoretically you could use an Order Statistic Tree if you want to get a specific element at a value, or just some kind of B-Tree in general to store the values. If they change, you are changing O(log n) items in the worst case. If you have 30,000 items, you only need to change 4 or 5 or them to keep the order.

提交回复
热议问题