All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.vipcxj.jasync.ng.runtime.utils.ImmutableDisposableStack Maven / Gradle / Ivy

package io.github.vipcxj.jasync.ng.runtime.utils;

public class ImmutableDisposableStack {

    private final T data;
    private final ImmutableDisposableStack next;

    private ImmutableDisposableStack(T data, ImmutableDisposableStack next) {
        this.data = data;
        this.next = next;
    }

    public static  ImmutableDisposableStack create(T data) {
        return new ImmutableDisposableStack<>(data, null);
    }

    public static  ImmutableDisposableStack create(T data1, T data2) {
        return new ImmutableDisposableStack<>(data1, create(data2));
    }

    public ImmutableDisposableStack push(T data) {
        return new ImmutableDisposableStack<>(data, this);
    }

    public T top() {
        return data;
    }

    public ImmutableDisposableStack pop() {
        return next;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy