1
0
mirror of https://github.com/golang/go synced 2024-10-04 16:31:22 -06:00
Commit Graph

93 Commits

Author SHA1 Message Date
Robert Griesemer
b2d1a2b513 container/heap: update example code
- use Init to establish heap invariant on
  a non-empty heap
- use Fix to update heap after an element's
  properties have been changed

(The old code used Init where it wasn't needed,
 and didn't use Fix because Fix was added after
 the example was written.)

LGTM=bradfitz
R=adonovan, bradfitz
CC=golang-codereviews
https://golang.org/cl/94520043
2014-05-15 13:58:13 -07:00
Robert Griesemer
f3913624a7 std lib: fix various typos in comments
Where the spelling changed from British to
US norm (e.g., optimise -> optimize) it follows
the style in that file.

LGTM=adonovan
R=golang-codereviews, adonovan
CC=golang-codereviews
https://golang.org/cl/96980043
2014-05-02 13:17:55 -07:00
Rui Ueyama
fb91559fbd all: fix typos
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/88670043
2014-04-16 16:57:25 -07:00
Markus Zimmermann
e0bb5ba52c container/list: mark must be an element of the list
The methods MoveAfter and MoveBefore of the container/list package did silently corrupt the interal structure of the list if a mark element is used which is not an element of the list.

LGTM=gri
R=golang-codereviews, gobot, gri
CC=golang-codereviews
https://golang.org/cl/60980043
2014-02-13 16:43:52 -08:00
Robert Griesemer
4d1301949a container/heap: avoid and/or ambiguity in documentation
(per suggestion by Doug McIlroy)

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/50580046
2014-02-10 12:48:56 -08:00
Shawn Smith
48334e3e91 container/list: improve test coverage
R=golang-codereviews, dave, gobot, bradfitz, gri
CC=golang-codereviews
https://golang.org/cl/46640043
2014-01-05 07:48:32 +11:00
Shawn Smith
a1731ac078 container/ring: add test for Move with empty Ring
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/46630044
2013-12-31 21:18:40 +11:00
Caleb Spare
e9895d92e0 container/list: Add missing period to doc comment for Front
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/38540046
2013-12-17 14:21:11 -08:00
Richard Eric Gavaletz
7adb42eee4 container/list: unexpected panic if Next/Prev called outside of list.
Before CL 7065067 calling Next on an element returned either the
next/prev element or nil was returned.  After the CL if an element
was not part of a list e.Next() and e.Prev() will panic.  This CL
returns to the documented behavior, that Next/Prev returns the
next/prev list element or nil.

Fixes #6349.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/13234051
2013-09-09 15:41:36 -07:00
Rob Pike
077989cf94 container/list: fix typo in comment
Fixes #6058.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12643043
2013-08-08 12:41:19 +10:00
Pieter Droogendijk
dd6f49ddca container/heap: add Fix and document the min is element 0.
Fixes #5372.
Fixes #5577.

R=gri, rsc, bradfitz, r
CC=golang-dev
https://golang.org/cl/12265043
2013-08-05 15:45:39 -07:00
Pieter Droogendijk
fbcc24bb9d container/list: added MoveBefore and MoveAfter
Fixes #4940.

R=golang-dev, bradfitz, gri
CC=golang-dev
https://golang.org/cl/12021044
2013-07-31 14:11:25 -07:00
Robert Griesemer
12a38d5b95 container/list: document complexity of Len
Fixes #5972.

R=golang-dev, adonovan
CC=golang-dev
https://golang.org/cl/12125043
2013-07-30 13:35:14 -07:00
Stefan Nilsson
d4a020dec1 container/heap: fix int overflow bug
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7450052
2013-03-04 10:25:21 -05:00
Robin Eklind
d137a2cb56 src: use internal tests if possible
If a test can be placed in the same package ("internal"), it is placed
there. This facilitates testing of package-private details. Because of
dependency cycles some packages cannot be tested by internal tests.

R=golang-dev, rsc, mikioh.mikioh
CC=golang-dev, r
https://golang.org/cl/7323044
2013-02-19 10:02:01 -05:00
Andrew Gerrand
66c96f1abc container/list: add package example
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7306078
2013-02-11 17:59:52 +11:00
Caleb Spare
dff017ea99 container/heap: fix comment typo in example test
This updates a bad reference to a method name in the example priority queue test.

The error was introduced in the example refactoring in rev. 2ea8f07b2ffe.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7279045
2013-02-05 07:06:00 -05:00
Nigel Tao
4e285bac6e container/heap: fix package doc comment about ordering.
R=gri, rsc
CC=golang-dev
https://golang.org/cl/7280044
2013-02-04 15:30:41 +11:00
Caleb Spare
0e74f04acc container/heap: split example into two
This adds a simple IntHeap example, and modifies the more complex
PriorityQueue example to make use of the index field it maintains.

Fixes #4331.

R=rsc, adg
CC=golang-dev
https://golang.org/cl/7068048
2013-01-30 23:14:29 -08:00
Robert Griesemer
ecb75486f8 container/list: avoid memory leaks
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7065067
2013-01-09 15:22:48 -08:00
Frithjof Schulze
cfc0a59d6e container/heap: Simplify the example.
Using append simplifies the code and makes it work if
the initial capacity of the slice is smaller than the
number of items pushed.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/6869060
2012-12-04 14:11:33 -08:00
Shenghou Ma
42c8904fe1 all: fix the the typos
Fixes #4420.

R=golang-dev, rsc, remyoudompheng
CC=golang-dev
https://golang.org/cl/6854080
2012-11-22 02:58:24 +08:00
Taj Khattra
1158c6b9c6 container/list: fix typo
R=golang-dev, fullung, dave, minux.ma
CC=golang-dev
https://golang.org/cl/6682046
2012-10-28 21:16:50 +11:00
Taj Khattra
c12dab2aa6 container/heap: optimization in case heap has many duplicates
benchmark       old ns/op    new ns/op    delta
BenchmarkDup      3075682       609448  -80.18%

R=gri
CC=golang-dev
https://golang.org/cl/6613064
2012-10-10 11:35:57 -07:00
Robert Griesemer
de782dd146 container/list: slightly better code factoring
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6569077
2012-09-28 10:58:46 -07:00
Robert Griesemer
0e9daef2d1 container/list: Correctly maintain internal invariants
The previous implementation was a mess with invariants
maintained inconsistently. Essentially reimplemented
the package:

- used a circular list as internal representation for
  significantly simpler implementation with fewer
  special cases while maintaining the illusion of
  a nil-terminated doubly linked list externally

- more precise documentation

- cleaned up and simplified tests, added test case
  for issue 4103.

No changes to the API or documented semantics.

All this said, I would be in favor of removing
this package eventually. container/ring provides
a faster implementation and a simpler and more
powerful API.

Fixes #4103.

R=r
CC=golang-dev
https://golang.org/cl/6569072
2012-09-28 10:35:32 -07:00
Andrew Gerrand
11e113db57 godoc: make example code more readable with new comment convention
go/doc: move Examples to go/ast
cmd/go: use go/doc to read examples
src/pkg: update examples to use new convention

This is to make whole file examples more readable. When presented as a
complete function, preceding an Example with its output is confusing.
The new convention is to put the expected output in the final comment
of the example, preceded by the string "output:" (case insensitive).

An idiomatic example looks like this:

// This example demonstrates Foo by doing bar and quux.
func ExampleFoo() {
        // example body that does bar and quux

        // Output:
        // example output
}

R=rsc, gri
CC=golang-dev
https://golang.org/cl/5673053
2012-02-16 11:50:28 +11:00
Andrew Gerrand
f3c3130685 godoc: support for package examples, display example suffixes
Fixes #2896.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5677047
2012-02-16 09:44:01 +11:00
Rob Pike
44fa114dc6 container/heap: add example
godoc doesn't have the fu to present the example well, but this gives
us an example of an example to develop example fu.

Fixes #2840.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5645063
2012-02-10 10:07:55 +11:00
Russ Cox
2050a9e478 build: remove Make.pkg, Make.tool
Consequently, remove many package Makefiles,
and shorten the few that remain.

gomake becomes 'go tool make'.

Turn off test phases of run.bash that do not work,
flagged with $BROKEN.  Future CLs will restore these,
but this seemed like a big enough CL already.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5601057
2012-01-30 23:43:46 -05:00
Rob Pike
4c40558c74 container/heap: better package documentation
Fixes #1820.

R=golang-dev, bradfitz, gri
CC=golang-dev
https://golang.org/cl/5540073
2012-01-17 13:07:47 -08:00
Russ Cox
41dc7d3a99 container/heap: document what Push and Pop do
Now that vector is gone, there is no precedent to refer to.
This is a confusing point for people looking to use the
package.

R=golang-dev, r, cw
CC=golang-dev
https://golang.org/cl/5322069
2011-11-03 15:30:57 -04:00
Russ Cox
965845a86d all: sort imports
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5319072
2011-11-02 15:54:16 -04:00
Rob Pike
f4cb96b438 container/vector: delete
Slices are better:
http://code.google.com/p/go-wiki/wiki/SliceTricks

R=golang-dev, bradfitz, dsymonds
CC=golang-dev
https://golang.org/cl/5248060
2011-10-11 16:41:48 -07:00
Rob Pike
ab1c164ecd container/heap/heap_test.go: remove container/vector
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4919044
2011-08-22 13:55:22 +10:00
Robert Griesemer
90564a9256 go/printer: changed max. number of newlines from 3 to 2
manual changes in src/pkg/go/printer, src/cmd/gofix/signal_test.go
(cd src/cmd/gofix/testdata; gofmt -w *.in *.out)
(cd src/pkg/go/printer; gotest -update)
gofmt -w misc src

runs all tests

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4715041
2011-07-14 14:39:40 -07:00
Robert Hencke
c8727c81bb pkg: spelling tweaks, A-H
R=ality, bradfitz, rsc, dsymonds, adg, qyzhai, dchest
CC=golang-dev
https://golang.org/cl/4536063
2011-05-18 13:14:56 -04:00
David Symonds
d911b872ce container/heap: fix circular dependency in test
Having the test be in the container/heap package yields a cycle
  container/heap (for the test)
  -> testing
  -> time
  -> container/heap (for timerHeap)

Occasionally the linker would get mixed up, resulting in a test panic
in a very weird place.

R=rsc, r2
CC=golang-dev
https://golang.org/cl/4395042
2011-04-22 16:29:05 -04:00
Nigel Tao
6a186d38d1 src/pkg: make package doc comments consistently start with "Package foo".
R=rsc
CC=golang-dev
https://golang.org/cl/4442064
2011-04-20 09:57:05 +10:00
Rob Pike
7f9acb53cb testing: shorten some more tests
R=rsc
CC=golang-dev
https://golang.org/cl/4314044
2011-03-26 11:25:22 -07:00
Kyle Consalus
3629d72328 container/ring: Replace Iter() with Do().
Faster in most cases, and not prone to memory leaks. Named "Do" to match with similarly named method on Vector.

R=gri
CC=golang-dev
https://golang.org/cl/4134046
2011-02-08 20:07:05 -08:00
Russ Cox
f2b5a07453 delete float, complex - code changes
also:
	cmplx -> complex
	float64(1.0) -> 1.0
	float64(1) -> 1.0

R=gri, r, gri1, r2
CC=golang-dev
https://golang.org/cl/3991043
2011-01-19 23:09:00 -05:00
Ryan Hitchman
062406bc64 throughout: simplify two-variable ranges with unused second variable
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/3529041
2010-12-08 21:36:56 -08:00
Rob Pike
1ce6245d6c throughout: fix broken calls to Printf etc.
I have written a tool to verify Printf calls, and although it's not
ready to be reviewed yet it's already uncovered a spate of problems
in the repository.  I'm sending this CL to break the changes into
pieces; as the tool improves it will find more, I'm sure.

R=rsc
CC=golang-dev
https://golang.org/cl/3427043
2010-12-07 16:42:54 -05:00
Roger Peppe
e9afb9d399 container/list: make Remove return Value of removed element.
When it is known that there is already at least one element in the
list, it is awkwardly verbose to use three lines and an extra
variable declaration to remove the first or last item (a common
case), rather than use a simple expression.

a stack:
	stk.PushFront(x)
	x = stk.Front().Remove().(T)

vs.
	stk.PushFront(x)
	e := stk.Front()
	e.Remove()
	x = e.Value.(T)
[An alternative CL might be to add PopFront and PopBack methods].

R=gri
CC=golang-dev
https://golang.org/cl/3000041
2010-11-09 08:58:23 -08:00
Andrew Gerrand
6062515a93 container/list: document iteration
R=rsc
CC=golang-dev
https://golang.org/cl/2768042
2010-10-29 08:48:16 +11:00
Andrew Gerrand
32a6613e94 container/list: elide redundant tests and fix comment typo
R=dsymonds
CC=golang-dev
https://golang.org/cl/2700041
2010-10-25 14:50:47 +11:00
Andrew Gerrand
01389b966e container/list: fix Remove bug and use pointer to self as identifier
Remove wasn't nil'ing the *Element.id. This property was exploited
by MoveToFront and MoveToBack internally, so I renamed the existing
Remove to "remove", and created an exported wrapper "Remove" that does
the right thing for the user's sake.

Also, saved an allocation by using *List as the id rather than *byte.

Fixes #1224.

R=rsc, dsymonds
CC=golang-dev
https://golang.org/cl/2685042
2010-10-25 14:37:30 +11:00
Russ Cox
e6ecf9765a exp/iterable: delete
Package iterable has outlived its utility.

It is an interesting demonstration, but it encourages
people to use iteration over channels where simple
iteration over array indices or a linked list would be
cheaper, simpler, and have fewer races.

R=dsymonds, r
CC=golang-dev
https://golang.org/cl/2436041
2010-10-11 22:38:42 -04:00
Rob Pike
d94fedabb4 list: update comment to state that the zero value is ready to use.
R=gri
CC=golang-dev
https://golang.org/cl/2147042
2010-09-03 17:11:56 +10:00