astl
Version:
AssemblyScript-STL (Standard Template Library, migrated from the C++)
60 lines (51 loc) • 1.17 kB
text/typescript
import { List } from "./List";
export class Queue<T>
{
private data_: List<T>;
/* ---------------------------------------------------------
CONSTURCTORS
--------------------------------------------------------- */
public constructor()
{
this.data_ = new List();
}
public pop(): void
{
this.data_.pop_front();
}
public push(value: T): void
{
this.data_.push_back(value);
}
public swap(obj: Queue<T>): void
{
const data: List<T> = this.data_;
this.data_ = obj.data_;
obj.data_ = data;
}
/* ---------------------------------------------------------
ACCESSORS
--------------------------------------------------------- */
public size(): usize
{
return this.data_.size();
}
public empty(): boolean
{
return this.data_.empty();
}
public front(): T
{
return this.data_.front();
}
public back(): T
{
return this.data_.back();
}
}