feat(listx): add listx interface

This commit is contained in:
bandl 2021-10-21 16:18:30 +08:00
parent 2295fbcf40
commit 70a246f84c
2 changed files with 80 additions and 0 deletions

View File

@ -24,3 +24,15 @@ type StringXInterface interface {
Getrange(start, end int32) (string, error)
GetLength() int
}
type ListXInterface interface {
KeyBaseInterface
LPush([]string) UpdateLength
RPush([]string) UpdateLength
LPop(int) ([]string, UpdateLength, error)
RPop(int) ([]string, UpdateLength, error)
Index(int) (string, error)
Insert(int, bool, []string) (UpdateLength, error)
Length() int
Slice(start, end int) (UpdateLength, error) // 切片, O(n)复杂度
}

View File

@ -0,0 +1,68 @@
package listx
import "gitee.com/timedb/wheatCache/pkg/structure"
/*
1. 双向链表
2. 支持头尾操作
3. 支持索引
4. 支持切片
*/
type Listx struct {
}
func (l *Listx) SizeByte() int64 {
panic("not implemented") // TODO: Implement
}
// RollBack TODO 事务相关, V2 实现
func (l *Listx) RollBack() error {
panic("not implemented") // TODO: Implement
}
// Begin 事务相关, V2 实现
func (l *Listx) Begin() error {
panic("not implemented") // TODO: Implement
}
// Comment 事务相关, V2 实现
func (l *Listx) Comment() error {
panic("not implemented") // TODO: Implement
}
func (l *Listx) Encode() ([]byte, error) {
panic("not implemented") // TODO: Implement
}
func (l *Listx) LPush(_ []string) structure.UpdateLength {
panic("not implemented") // TODO: Implement
}
func (l *Listx) RPush(_ []string) structure.UpdateLength {
panic("not implemented") // TODO: Implement
}
func (l *Listx) LPop(_ int) ([]string, structure.UpdateLength, error) {
panic("not implemented") // TODO: Implement
}
func (l *Listx) RPop(_ int) ([]string, structure.UpdateLength, error) {
panic("not implemented") // TODO: Implement
}
func (l *Listx) Index(_ int) (string, error) {
panic("not implemented") // TODO: Implement
}
func (l *Listx) Insert(_ int, _ bool, _ []string) (structure.UpdateLength, error) {
panic("not implemented") // TODO: Implement
}
func (l *Listx) Length() int {
panic("not implemented") // TODO: Implement
}
func (l *Listx) Slice(start int, end int) (structure.UpdateLength, error) {
panic("not implemented") // TODO: Implement
}