mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-18 00:08:31 +00:00
[Update] 优化树结构
This commit is contained in:
25
apps/common/struct.py
Normal file
25
apps/common/struct.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
|
||||
|
||||
class Stack(list):
|
||||
def is_empty(self):
|
||||
return len(self) == 0
|
||||
|
||||
@property
|
||||
def top(self):
|
||||
if self.is_empty():
|
||||
return None
|
||||
return self[-1]
|
||||
|
||||
@property
|
||||
def bottom(self):
|
||||
if self.is_empty():
|
||||
return None
|
||||
return self[0]
|
||||
|
||||
def size(self):
|
||||
return len(self)
|
||||
|
||||
def push(self, item):
|
||||
self.append(item)
|
Reference in New Issue
Block a user