EwdAger / Po-Struct

Replicating Python basic data structures with Golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Po-Struct

使用 Go 实现 Python 中的基础数据结构及其特性,包括但不限于:

  • float
  • int
  • bytes
  • str
  • list
  • dict

结构特性

list

参考 Python List 设计,实现了自动扩缩容

  • Srting()序列化
  • Size()获取长度
  • Cap()获取容量
  • GetItem()获取元素,含反向索引 l.GetItem(-1)
  • SetItem()设置元素,含反向索引
  • Append()尾部添加,可添加多个元素
  • Insert()中间插入,含反向索引
  • GetSlice()中间切片,含反向索引
  • Extend()拼接
  • Reverse()倒转
  • Pop()尾部出栈,删除指定位置元素
  • Clear()清空
  • Range() 接受一个方法,遍历
  • Sort()排序

set

  • Srting()序列化
  • Size()获取长度
  • Copy()拷贝
  • IsSubSet()判断子集
  • IsSuperSet()判断超集
  • Equal()判断相等
  • Union()返回并集
  • Difference()返回差集
  • Intersection()返回交集
  • Range() 接受一个方法,遍历

float

  • 对象缓冲池

int

  • 小数静态对象池
  • 不溢出的大数运算

About

Replicating Python basic data structures with Golang


Languages

Language:Go 100.0%