ADDED src/0dev.org/types/types.go Index: src/0dev.org/types/types.go ================================================================== --- /dev/null +++ src/0dev.org/types/types.go @@ -0,0 +1,115 @@ +// Package types provides alias types for builtins +// that implement interfaces such as sort.Interface +package types + +type Unsigned8 []uint8 + +func (u Unsigned8) Len() int { + return len(u) +} + +func (u Unsigned8) Less(i, j int) bool { + return u[i] < u[j] +} + +func (u Unsigned8) Swap(i, j int) { + u[i], u[j] = u[j], u[i] +} + +type Unsigned16 []uint16 + +func (u Unsigned16) Len() int { + return len(u) +} + +func (u Unsigned16) Less(i, j int) bool { + return u[i] < u[j] +} + +func (u Unsigned16) Swap(i, j int) { + u[i], u[j] = u[j], u[i] +} + +type Unsigned32 []uint32 + +func (u Unsigned32) Len() int { + return len(u) +} + +func (u Unsigned32) Less(i, j int) bool { + return u[i] < u[j] +} + +func (u Unsigned32) Swap(i, j int) { + u[i], u[j] = u[j], u[i] +} + +type Unsigned64 []uint64 + +func (u Unsigned64) Len() int { + return len(u) +} + +func (u Unsigned64) Less(i, j int) bool { + return u[i] < u[j] +} + +func (u Unsigned64) Swap(i, j int) { + u[i], u[j] = u[j], u[i] +} + +type Signed8 []uint8 + +func (u Signed8) Len() int { + return len(u) +} + +func (u Signed8) Less(i, j int) bool { + return u[i] < u[j] +} + +func (u Signed8) Swap(i, j int) { + u[i], u[j] = u[j], u[i] +} + +type Signed16 []uint16 + +func (u Signed16) Len() int { + return len(u) +} + +func (u Signed16) Less(i, j int) bool { + return u[i] < u[j] +} + +func (u Signed16) Swap(i, j int) { + u[i], u[j] = u[j], u[i] +} + +type Signed32 []uint32 + +func (u Signed32) Len() int { + return len(u) +} + +func (u Signed32) Less(i, j int) bool { + return u[i] < u[j] +} + +func (u Signed32) Swap(i, j int) { + u[i], u[j] = u[j], u[i] +} + +type Signed64 []uint64 + +func (u Signed64) Len() int { + return len(u) +} + +func (u Signed64) Less(i, j int) bool { + return u[i] < u[j] +} + +func (u Signed64) Swap(i, j int) { + u[i], u[j] = u[j], u[i] +}