mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2026-03-20 02:42:50 +01:00
add TimeZone selection in settings
This commit is contained in:
63
sysgo/UI/folder_stack.go
Normal file
63
sysgo/UI/folder_stack.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package UI
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
)
|
||||
|
||||
type FolderStack struct {
|
||||
lock *sync.Mutex
|
||||
head *element
|
||||
Size int
|
||||
RootPath string
|
||||
}
|
||||
|
||||
func (stk *FolderStack) Push(data interface{}) {
|
||||
stk.lock.Lock()
|
||||
|
||||
element := new(element)
|
||||
element.data = data
|
||||
temp := stk.head
|
||||
element.next = temp
|
||||
stk.head = element
|
||||
stk.Size++
|
||||
|
||||
stk.lock.Unlock()
|
||||
}
|
||||
|
||||
func (stk *FolderStack) Pop() interface{} {
|
||||
if stk.head == nil {
|
||||
return nil
|
||||
}
|
||||
stk.lock.Lock()
|
||||
r := stk.head.data
|
||||
stk.head = stk.head.next
|
||||
stk.Size--
|
||||
|
||||
stk.lock.Unlock()
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (stk *FolderStack) SetRootPath(path string) {
|
||||
stk.RootPath = path
|
||||
}
|
||||
|
||||
func (stk *FolderStack) Length() int {
|
||||
return stk.Size
|
||||
}
|
||||
|
||||
func (stk *FolderStack) Last() string {
|
||||
idx := stk.Length() -1
|
||||
if idx < 0 {
|
||||
return stk.RootPath
|
||||
}else {
|
||||
return stk.head.data.(string)
|
||||
}
|
||||
}
|
||||
|
||||
func NewFolderStack() *FolderStack {
|
||||
stk := new(FolderStack)
|
||||
stk.lock = &sync.Mutex{}
|
||||
return stk
|
||||
}
|
||||
Reference in New Issue
Block a user