lists

package
v0.0.0-...-cc5dc36 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2015 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Copyright 2015 mint.zhao.chiu@gmail.com

Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2015 mint.zhao.chiu@gmail.com

Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2015 mint.zhao.chiu@gmail.com

Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2015 mint.zhao.chiu@gmail.com

Licensed under the Apache License, Version 2.0 (the "License"): you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayList

type ArrayList struct {
	// contains filtered or unexported fields
}

func NewArrayList

func NewArrayList() *ArrayList

func (*ArrayList) Add

func (list *ArrayList) Add(elements ...interface{})

append elements at the end of the list

func (*ArrayList) Clear

func (list *ArrayList) Clear()

remove all the elements

func (*ArrayList) Clone

func (list *ArrayList) Clone() *ArrayList

func (*ArrayList) Contains

func (list *ArrayList) Contains(elements ...interface{}) bool

check if the elements are in the array list

func (*ArrayList) Elements

func (list *ArrayList) Elements() []interface{}

return all the elements in the arraylist

func (*ArrayList) Empty

func (list *ArrayList) Empty() bool

return true if the list's size is zero

func (*ArrayList) Get

func (list *ArrayList) Get(idx int) (interface{}, bool)

return the element at idx, if get the element, return element and true, otherwise nil, false

func (*ArrayList) Len

func (list *ArrayList) Len() int

return list's size

func (*ArrayList) Less

func (list *ArrayList) Less(i, j int) bool

func (*ArrayList) Remove

func (list *ArrayList) Remove(idx int)

remove the element form the arraylist

func (*ArrayList) Sort

func (list *ArrayList) Sort(comparators ...container.CompareFunction)

sort the elements by comparator

func (*ArrayList) String

func (list *ArrayList) String() string

out format

func (*ArrayList) Swap

func (list *ArrayList) Swap(i, j int)

type DoublyLinkedList

type DoublyLinkedList struct {
	// contains filtered or unexported fields
}

func NewDoublyLinkedList

func NewDoublyLinkedList() *DoublyLinkedList

func (*DoublyLinkedList) Add

func (list *DoublyLinkedList) Add(values ...interface{})

Appends a value (one or more) at the end of the list (same as Append())

func (*DoublyLinkedList) Append

func (list *DoublyLinkedList) Append(values ...interface{})

Appends a value (one or more) at the end of the list (same as Add())

func (*DoublyLinkedList) Clear

func (list *DoublyLinkedList) Clear()

Removes all elements from the list.

func (*DoublyLinkedList) Contains

func (list *DoublyLinkedList) Contains(values ...interface{}) bool

Check if values (one or more) are present in the set. All values have to be present in the set for the method to return true. Performance time complexity of n^2. Returns true if no arguments are passed at all, i.e. set is always super-set of empty set.

func (*DoublyLinkedList) Elements

func (list *DoublyLinkedList) Elements() []interface{}

Returns all elements in the list.

func (*DoublyLinkedList) Empty

func (list *DoublyLinkedList) Empty() bool

Returns true if list does not contain any elements.

func (*DoublyLinkedList) Get

func (list *DoublyLinkedList) Get(index int) (interface{}, bool)

Returns the element at index. Second return parameter is true if index is within bounds of the array and array is not empty, otherwise false.

func (*DoublyLinkedList) Len

func (list *DoublyLinkedList) Len() int

Returns number of elements within the list.

func (*DoublyLinkedList) Less

func (list *DoublyLinkedList) Less(i, j int) bool

func (*DoublyLinkedList) Prepend

func (list *DoublyLinkedList) Prepend(values ...interface{})

Prepends a values (or more)

func (*DoublyLinkedList) Remove

func (list *DoublyLinkedList) Remove(index int)

Removes one or more elements from the list with the supplied indices.

func (*DoublyLinkedList) Sort

func (list *DoublyLinkedList) Sort(comparators ...container.CompareFunction)

Sorts values

func (*DoublyLinkedList) String

func (list *DoublyLinkedList) String() string

func (*DoublyLinkedList) Swap

func (list *DoublyLinkedList) Swap(i, j int)

Swaps values of two elements at the given indices.

type ListInterface

type ListInterface interface {
	Get(idx int) (interface{}, bool)
	Remove(idx int)
	Add(elements ...interface{})
	Sort(comparators ...container.CompareFunction)

	container.ContainerInterface
}

type SinglyLinkedList

type SinglyLinkedList struct {
	// contains filtered or unexported fields
}

func NewSinglyLinkedList

func NewSinglyLinkedList() *SinglyLinkedList

func (*SinglyLinkedList) Add

func (list *SinglyLinkedList) Add(values ...interface{})

Appends a value (one or more) at the end of the list (same as Append())

func (*SinglyLinkedList) Append

func (list *SinglyLinkedList) Append(values ...interface{})

Appends a value (one or more) at the end of the list (same as Add())

func (*SinglyLinkedList) Clear

func (list *SinglyLinkedList) Clear()

Removes all elements from the list.

func (*SinglyLinkedList) Contains

func (list *SinglyLinkedList) Contains(values ...interface{}) bool

Check if values (one or more) are present in the set. All values have to be present in the set for the method to return true. Performance time complexity of n^2. Returns true if no arguments are passed at all, i.e. set is always super-set of empty set.

func (*SinglyLinkedList) Elements

func (list *SinglyLinkedList) Elements() []interface{}

Returns all elements in the list.

func (*SinglyLinkedList) Empty

func (list *SinglyLinkedList) Empty() bool

Returns true if list does not contain any elements.

func (*SinglyLinkedList) Get

func (list *SinglyLinkedList) Get(index int) (interface{}, bool)

Returns the element at index. Second return parameter is true if index is within bounds of the array and array is not empty, otherwise false.

func (*SinglyLinkedList) Len

func (list *SinglyLinkedList) Len() int

Returns number of elements within the list.

func (*SinglyLinkedList) Less

func (list *SinglyLinkedList) Less(i, j int) bool

func (*SinglyLinkedList) Prepend

func (list *SinglyLinkedList) Prepend(values ...interface{})

Prepends a values (or more)

func (*SinglyLinkedList) Remove

func (list *SinglyLinkedList) Remove(index int)

Removes one or more elements from the list with the supplied indices.

func (*SinglyLinkedList) Sort

func (list *SinglyLinkedList) Sort(comparators ...container.CompareFunction)

Sorts values (in-place) using timsort.

func (*SinglyLinkedList) String

func (list *SinglyLinkedList) String() string

func (*SinglyLinkedList) Swap

func (list *SinglyLinkedList) Swap(i, j int)

Swaps values of two elements at the given indices.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL