import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('Stack')
export class Stack<T> 
{
    objects: T[] = [];

    public fn_Push(obj: T)
    {
        this.objects.push(obj);
    }

    public fn_Pop() : T
    {
        return this.objects.pop();
    }

    public fn_Peek() : T 
    {
        return this.objects[this.objects.length - 1];
    }

    public fn_Size() : number 
    {
        return this.objects.length;
    }

    public fn_IsEmpty() : boolean
    {
        return this.objects == null || this.objects.length < 1;
    }

    public fn_Clear()
    {
        this.objects.splice(0, this.objects.length);
    }
}

