Best way to save a ordered List to the Database while keeping the ordering

前端 未结 12 1089
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-30 17:27

I was wondering if anyone has a good solution to a problem I\'ve encountered numerous times during the last years.

I have a shopping cart and my customer explicitly

12条回答
  •  -上瘾入骨i
    2020-11-30 17:53

    Best solution is a Doubly Linked list. O(1) for all operations except indexing. Nothing can index SQL quickly though except a where clause on the item you want.

    0,10,20 types fail. Sequence column ones fail. Float sequence column fails at group moves.

    Doubly Linked list is same operations for addition, removal, group deletion, group addition, group move. Single linked list works ok too. Double linked is better with SQL in my opinion though. Single linked list requires you to have the entire list.

提交回复
热议问题