* Implement a skip list for storing rooms This data structure stores rooms in a given sorted order and allows for very fast insertions and deletions. * Export function to get last timestamp of room * Write tests for the skip list * Implement enough of the new store to get a list of rooms * Make it possible to swap sorting algorithm * Fix comment * Don't attach to window object We don't want the store to be created if the labs flag is off * Remove the store class Probably best to include this PR with the minimal vm implmentation
30 lines
883 B
TypeScript
30 lines
883 B
TypeScript
/*
|
|
Copyright 2025 New Vector Ltd.
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
import type { Room } from "matrix-js-sdk/src/matrix";
|
|
|
|
/**
|
|
* Room skip list stores room nodes.
|
|
* These hold the actual room object and provides references to other nodes
|
|
* in different levels.
|
|
*/
|
|
export class RoomNode {
|
|
public constructor(public readonly room: Room) {}
|
|
|
|
/**
|
|
* This array holds references to the next node in a given level.
|
|
* eg: next[i] gives the next room node from this room node in level i.
|
|
*/
|
|
public next: RoomNode[] = [];
|
|
|
|
/**
|
|
* This array holds references to the previous node in a given level.
|
|
* eg: previous[i] gives the previous room node from this room node in level i.
|
|
*/
|
|
public previous: RoomNode[] = [];
|
|
}
|