2022-11-25 18:19:33 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022 tursom. All rights reserved.
|
|
|
|
* Use of this source code is governed by a GPL-3
|
|
|
|
* license that can be found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2021-05-22 17:10:26 +08:00
|
|
|
package collections
|
|
|
|
|
2022-04-23 11:53:41 +08:00
|
|
|
import (
|
|
|
|
"github.com/tursom/GoCollections/exceptions"
|
|
|
|
)
|
2021-05-22 17:10:26 +08:00
|
|
|
|
2022-04-23 11:53:41 +08:00
|
|
|
type (
|
|
|
|
Stack[T any] interface {
|
|
|
|
MutableIterable[T]
|
2021-05-22 17:10:26 +08:00
|
|
|
|
2022-04-23 11:53:41 +08:00
|
|
|
Push(element T) exceptions.Exception
|
|
|
|
PushAndGetNode(element T) (StackNode[T], exceptions.Exception)
|
|
|
|
Pop() (T, exceptions.Exception)
|
|
|
|
}
|
|
|
|
|
2022-04-24 16:01:22 +08:00
|
|
|
StackNode[T any] interface {
|
2022-04-23 11:53:41 +08:00
|
|
|
Set(value T) exceptions.Exception
|
|
|
|
Get() (T, exceptions.Exception)
|
|
|
|
Remove() exceptions.Exception
|
|
|
|
RemoveAndGet() (T, exceptions.Exception)
|
|
|
|
}
|
|
|
|
)
|