From 2ccfba5f938d22c6c06e2e0b815fe8ea522acfe5 Mon Sep 17 00:00:00 2001 From: Emir Pasic Date: Sat, 25 Jun 2016 05:51:41 +0200 Subject: [PATCH] - replace timsort with go's sort --- README.md | 7 ++++--- containers/containers.go | 1 - examples/sort.go | 2 +- lists/arraylist/arraylist.go | 2 +- lists/doublylinkedlist/doublylinkedlist.go | 2 +- lists/singlylinkedlist/singlylinkedlist.go | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e5297f5..f5a4c81 100644 --- a/README.md +++ b/README.md @@ -902,9 +902,11 @@ func main() { ### Sort -Sort uses timsort for best performance on real-world data. Lists have an in-place _Sort()_ method. All containers can return their sorted elements via _GetSortedValues()_ call. +Sort is a general purpose sort function. -Internally they use the _utils.Sort()_ method: +Lists have an in-place _Sort()_ function and all containers can return their sorted elements via _containers.GetSortedValues()_ function. + +Internally these all use the _utils.Sort()_ method: ```go package main @@ -928,7 +930,6 @@ Container specific operations: ```go // Returns sorted container''s elements with respect to the passed comparator. // Does not effect the ordering of elements within the container. -// Uses timsort. func GetSortedValues(container Container, comparator utils.Comparator) []interface{} ``` diff --git a/containers/containers.go b/containers/containers.go index 389d289..0a26c44 100644 --- a/containers/containers.go +++ b/containers/containers.go @@ -38,7 +38,6 @@ type Container interface { // GetSortedValues returns sorted container's elements with respect to the passed comparator. // Does not effect the ordering of elements within the container. -// Uses timsort. func GetSortedValues(container Container, comparator utils.Comparator) []interface{} { values := container.Values() if len(values) < 2 { diff --git a/examples/sort.go b/examples/sort.go index 5940886..e2fd713 100644 --- a/examples/sort.go +++ b/examples/sort.go @@ -28,7 +28,7 @@ package examples import "github.com/emirpasic/gods/utils" -// SortExample to demonstrate basic usage of basic sort (timsort) +// SortExample to demonstrate basic usage of basic sort func SortExample() { strings := []interface{}{} // [] strings = append(strings, "d") // ["d"] diff --git a/lists/arraylist/arraylist.go b/lists/arraylist/arraylist.go index 5e65f39..f471908 100644 --- a/lists/arraylist/arraylist.go +++ b/lists/arraylist/arraylist.go @@ -138,7 +138,7 @@ func (list *List) Clear() { list.elements = []interface{}{} } -// Sort sorts values (in-place) using timsort. +// Sort sorts values (in-place) using. func (list *List) Sort(comparator utils.Comparator) { if len(list.elements) < 2 { return diff --git a/lists/doublylinkedlist/doublylinkedlist.go b/lists/doublylinkedlist/doublylinkedlist.go index 8263cc6..58a0e4b 100644 --- a/lists/doublylinkedlist/doublylinkedlist.go +++ b/lists/doublylinkedlist/doublylinkedlist.go @@ -214,7 +214,7 @@ func (list *List) Clear() { list.last = nil } -// Sort sorts values (in-place) using timsort. +// Sort sorts values (in-place) using. func (list *List) Sort(comparator utils.Comparator) { if list.size < 2 { diff --git a/lists/singlylinkedlist/singlylinkedlist.go b/lists/singlylinkedlist/singlylinkedlist.go index aef92e2..baf028c 100644 --- a/lists/singlylinkedlist/singlylinkedlist.go +++ b/lists/singlylinkedlist/singlylinkedlist.go @@ -195,7 +195,7 @@ func (list *List) Clear() { list.last = nil } -// Sort sort values (in-place) using timsort. +// Sort sort values (in-place) using. func (list *List) Sort(comparator utils.Comparator) { if list.size < 2 {