/golist

python's list type implementation on go.

Primary LanguageGoMIT LicenseMIT

golist Build Status Clone in Koding

python's list type implementation on go.

installation

$ go get github.com/emre/golist

Initialization of a new List

my_list := golist.New()
my_list := golist.New("Galatasaray", "Real Madrid")

Appending items

my_list.Append("Drogba")
my_list.Append("Bruma")

Extending list with another list

other_list := golist.New("Ronaldo", "Bale")
my_list.Extend(other_list)

Get an index for the element

index, err := my_list.Index("Drogba")
if err != nil {
	fmt.Println(err)
}
fmt.Println(index)

Counting items

my_list.Append("Drogba", "Drogba")
drogba_count := my_list.Count("Drogba")
fmt.Println(drogba_count)

Deleting items by value/index

// by value
my_list.Remove("Drogba")

// by index
my_list.Delete(0)

Pop items

// pops the item which of index zero.
value, err := my_list.Pop(0)

// pops latest item
value, err := my_list.Pop()

Reversing a List

goals_list := golist.New("18:Drogba", "56:Bale", "90+2:Sabri Sarioglu")
goals_list.Reverse()

Get the size of list

list_size := goals_list.Len()

Further documentation

Bitdeli Badge