Skip to content

Commit

Permalink
Khaaz#69 reflections
Browse files Browse the repository at this point in the history
  • Loading branch information
bsian03 committed Mar 14, 2020
1 parent cdc4dbc commit 3fd41e0
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 40 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ declare namespace AxonCore {
export import MessageCollector = Types.MessageCollector;
export import Prompt = Types.Prompt;
export import ReactionCollector = Types.ReactionCollector;
export import TimeoutQueue = Types.TimeoutQueue;
export import SortedList = Types.SortedList;
export import AsyncQueue = Types.AsyncQueue;
export import AutoQueue = Types.AutoQueue;
export import FunctionQueue = Types.FunctionQueue;
Expand Down
4 changes: 2 additions & 2 deletions types/Utility/Discord/Collectors/Collector.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EventEmitter } from 'events';
import {
Collection, TimeoutQueue, AxonClient, CollectorContainer, LibClient, LibraryInterface,
Collection, SortedList, AxonClient, CollectorContainer, LibClient, LibraryInterface, Timeout,
} from '../../../';

/**
Expand Down Expand Up @@ -35,7 +35,7 @@ export declare class Collector<T> extends EventEmitter {
/** Collection of CollectorContainer */
public collectors: Collection<CollectorContainer<T>>;
/** The current timeout queue sorted with the first timeout due at the top of the queue */
public timeoutQueue: TimeoutQueue;
public timeoutQueue: SortedList<Timeout>;
/** Unique increment count used to generate ids */
private _INCREMENT: number;
/** Whether the Collector is currently running */
Expand Down
36 changes: 0 additions & 36 deletions types/Utility/Discord/Collectors/TimeoutQueue.ts

This file was deleted.

59 changes: 59 additions & 0 deletions types/Utility/External/SortedList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* SortedList Object. Sorted Array of element (ascending or descending order)
* @author KhaaZ
* @class SortedList
*/
export declare class SortedList<T> {
public ascending: boolean;
/** Whether toInsert is bigger than baseElement */
public comparator: (toInsert: T, baseElement: T) => boolean;
public list: T[];
/**
* Creates an instance of SortedList
* @memberof SortedList
*/
constructor(comparator?: (toInsert: T, baseElement: T) => boolean, ascending?: boolean);

/**
* Size of the list
* @readonly
* @memberof SortedList
*/
public size: number;

/**
* Whether the list is empty or not
* @memberof SortedList
*/
public isEmpty(): boolean;
/**
* Returns the first element of the list without removing it
* @memberof SortedList
*/
public first(): T;
/**
* Returns the first element of the list without removing it
* @memberof SortedList
*/
public first(): T;
/**
* Returns the last element of the list without removing it
* @memberof SortedList
*/
public last(): T;
/**
* Adds an element in the queue, sorting by ascending timeout
* @memberof SortedList
*/
add(element: T, comparator?: (toInsert: T, baseElement: T) => boolean): void;
/**
* Get the first element in the queue and removes it
* @memberof SortedList
*/
shift(): T;
/**
* Get the last element in the queue and removes it
* @memberof SortedList
*/
pop(): T;
}
2 changes: 1 addition & 1 deletion types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export { Prompt } from './Utility/Discord/Prompt';
export { ReactionCollector } from './Utility/Discord/Collectors/ReactionCollector';
export { MessageCollector } from './Utility/Discord/Collectors/MessageCollector';
export { Collector } from './Utility/Discord/Collectors/Collector';
export { TimeoutQueue } from './Utility/Discord/Collectors/TimeoutQueue';
export { SortedList } from './Utility/External/SortedList';

export { AsyncQueue } from './Utility/External/AsyncQueue';
export { AutoQueue } from './Utility/External/AutoQueue';
Expand Down

0 comments on commit 3fd41e0

Please sign in to comment.