Interface implementation assertions moved outside the functions

pull/197/head
Emir Pasic 2 years ago
parent 363df0e21f
commit e2b92bbc7a

@ -17,9 +17,8 @@ import (
"github.com/emirpasic/gods/utils"
)
func assertListImplementation() {
var _ lists.List = (*List)(nil)
}
// Assert List implementation
var _ lists.List = (*List)(nil)
// List holds the elements in a slice
type List struct {

@ -6,9 +6,8 @@ package arraylist
import "github.com/emirpasic/gods/containers"
func assertEnumerableImplementation() {
var _ containers.EnumerableWithIndex = (*List)(nil)
}
// Assert Enumerable implementation
var _ containers.EnumerableWithIndex = (*List)(nil)
// Each calls the given function once for each element, passing that element's index and value.
func (list *List) Each(f func(index int, value interface{})) {

@ -6,9 +6,8 @@ package arraylist
import "github.com/emirpasic/gods/containers"
func assertIteratorImplementation() {
var _ containers.ReverseIteratorWithIndex = (*Iterator)(nil)
}
// Assert Iterator implementation
var _ containers.ReverseIteratorWithIndex = (*Iterator)(nil)
// Iterator holding the iterator's state
type Iterator struct {

@ -9,10 +9,9 @@ import (
"github.com/emirpasic/gods/containers"
)
func assertSerializationImplementation() {
var _ containers.JSONSerializer = (*List)(nil)
var _ containers.JSONDeserializer = (*List)(nil)
}
// Assert Serialization implementation
var _ containers.JSONSerializer = (*List)(nil)
var _ containers.JSONDeserializer = (*List)(nil)
// ToJSON outputs the JSON representation of list's elements.
func (list *List) ToJSON() ([]byte, error) {

@ -17,9 +17,8 @@ import (
"github.com/emirpasic/gods/utils"
)
func assertListImplementation() {
var _ lists.List = (*List)(nil)
}
// Assert List implementation
var _ lists.List = (*List)(nil)
// List holds the elements, where each element points to the next and previous element
type List struct {

@ -6,9 +6,8 @@ package doublylinkedlist
import "github.com/emirpasic/gods/containers"
func assertEnumerableImplementation() {
var _ containers.EnumerableWithIndex = (*List)(nil)
}
// Assert Enumerable implementation
var _ containers.EnumerableWithIndex = (*List)(nil)
// Each calls the given function once for each element, passing that element's index and value.
func (list *List) Each(f func(index int, value interface{})) {

@ -6,9 +6,8 @@ package doublylinkedlist
import "github.com/emirpasic/gods/containers"
func assertIteratorImplementation() {
var _ containers.ReverseIteratorWithIndex = (*Iterator)(nil)
}
// Assert Iterator implementation
var _ containers.ReverseIteratorWithIndex = (*Iterator)(nil)
// Iterator holding the iterator's state
type Iterator struct {

@ -9,10 +9,9 @@ import (
"github.com/emirpasic/gods/containers"
)
func assertSerializationImplementation() {
var _ containers.JSONSerializer = (*List)(nil)
var _ containers.JSONDeserializer = (*List)(nil)
}
// Assert Serialization implementation
var _ containers.JSONSerializer = (*List)(nil)
var _ containers.JSONDeserializer = (*List)(nil)
// ToJSON outputs the JSON representation of list's elements.
func (list *List) ToJSON() ([]byte, error) {

@ -6,9 +6,8 @@ package singlylinkedlist
import "github.com/emirpasic/gods/containers"
func assertEnumerableImplementation() {
var _ containers.EnumerableWithIndex = (*List)(nil)
}
// Assert Enumerable implementation
var _ containers.EnumerableWithIndex = (*List)(nil)
// Each calls the given function once for each element, passing that element's index and value.
func (list *List) Each(f func(index int, value interface{})) {

@ -6,9 +6,8 @@ package singlylinkedlist
import "github.com/emirpasic/gods/containers"
func assertIteratorImplementation() {
var _ containers.IteratorWithIndex = (*Iterator)(nil)
}
// Assert Iterator implementation
var _ containers.IteratorWithIndex = (*Iterator)(nil)
// Iterator holding the iterator's state
type Iterator struct {

@ -9,10 +9,9 @@ import (
"github.com/emirpasic/gods/containers"
)
func assertSerializationImplementation() {
var _ containers.JSONSerializer = (*List)(nil)
var _ containers.JSONDeserializer = (*List)(nil)
}
// Assert Serialization implementation
var _ containers.JSONSerializer = (*List)(nil)
var _ containers.JSONDeserializer = (*List)(nil)
// ToJSON outputs the JSON representation of list's elements.
func (list *List) ToJSON() ([]byte, error) {

@ -17,9 +17,8 @@ import (
"github.com/emirpasic/gods/utils"
)
func assertListImplementation() {
var _ lists.List = (*List)(nil)
}
// Assert List implementation
var _ lists.List = (*List)(nil)
// List holds the elements, where each element points to the next element
type List struct {

@ -21,9 +21,8 @@ import (
"github.com/emirpasic/gods/maps/hashmap"
)
func assertMapImplementation() {
var _ maps.BidiMap = (*Map)(nil)
}
// Assert Map implementation
var _ maps.BidiMap = (*Map)(nil)
// Map holds the elements in two hashmaps.
type Map struct {

@ -9,10 +9,9 @@ import (
"github.com/emirpasic/gods/containers"
)
func assertSerializationImplementation() {
var _ containers.JSONSerializer = (*Map)(nil)
var _ containers.JSONDeserializer = (*Map)(nil)
}
// Assert Serialization implementation
var _ containers.JSONSerializer = (*Map)(nil)
var _ containers.JSONDeserializer = (*Map)(nil)
// ToJSON outputs the JSON representation of the map.
func (m *Map) ToJSON() ([]byte, error) {

@ -16,9 +16,8 @@ import (
"github.com/emirpasic/gods/maps"
)
func assertMapImplementation() {
var _ maps.Map = (*Map)(nil)
}
// Assert Map implementation
var _ maps.Map = (*Map)(nil)
// Map holds the elements in go's native map
type Map struct {

@ -10,10 +10,9 @@ import (
"github.com/emirpasic/gods/utils"
)
func assertSerializationImplementation() {
var _ containers.JSONSerializer = (*Map)(nil)
var _ containers.JSONDeserializer = (*Map)(nil)
}
// Assert Serialization implementation
var _ containers.JSONSerializer = (*Map)(nil)
var _ containers.JSONDeserializer = (*Map)(nil)
// ToJSON outputs the JSON representation of the map.
func (m *Map) ToJSON() ([]byte, error) {

@ -6,9 +6,8 @@ package linkedhashmap
import "github.com/emirpasic/gods/containers"
func assertEnumerableImplementation() {
var _ containers.EnumerableWithKey = (*Map)(nil)
}
// Assert Enumerable implementation
var _ containers.EnumerableWithKey = (*Map)(nil)
// Each calls the given function once for each element, passing that element's key and value.
func (m *Map) Each(f func(key interface{}, value interface{})) {

@ -9,9 +9,8 @@ import (
"github.com/emirpasic/gods/lists/doublylinkedlist"
)
func assertIteratorImplementation() {
var _ containers.ReverseIteratorWithKey = (*Iterator)(nil)
}
// Assert Iterator implementation
var _ containers.ReverseIteratorWithKey = (*Iterator)(nil)
// Iterator holding the iterator's state
type Iterator struct {

@ -18,9 +18,8 @@ import (
"strings"
)
func assertMapImplementation() {
var _ maps.Map = (*Map)(nil)
}
// Assert Map implementation
var _ maps.Map = (*Map)(nil)
// Map holds the elements in a regular hash table, and uses doubly-linked list to store key ordering.
type Map struct {

@ -11,10 +11,9 @@ import (
"github.com/emirpasic/gods/utils"
)
func assertSerializationImplementation() {
var _ containers.JSONSerializer = (*Map)(nil)
var _ containers.JSONDeserializer = (*Map)(nil)
}
// Assert Serialization implementation
var _ containers.JSONSerializer = (*Map)(nil)
var _ containers.JSONDeserializer = (*Map)(nil)
// ToJSON outputs the JSON representation of map.
func (m *Map) ToJSON() ([]byte, error) {

@ -6,9 +6,8 @@ package treebidimap
import "github.com/emirpasic/gods/containers"
func assertEnumerableImplementation() {
var _ containers.EnumerableWithKey = (*Map)(nil)
}
// Assert Enumerable implementation
var _ containers.EnumerableWithKey = (*Map)(nil)
// Each calls the given function once for each element, passing that element's key and value.
func (m *Map) Each(f func(key interface{}, value interface{})) {

@ -9,9 +9,8 @@ import (
rbt "github.com/emirpasic/gods/trees/redblacktree"
)
func assertIteratorImplementation() {
var _ containers.ReverseIteratorWithKey = (*Iterator)(nil)
}
// Assert Iterator implementation
var _ containers.ReverseIteratorWithKey = (*Iterator)(nil)
// Iterator holding the iterator's state
type Iterator struct {

@ -10,10 +10,9 @@ import (
"github.com/emirpasic/gods/utils"
)
func assertSerializationImplementation() {
var _ containers.JSONSerializer = (*Map)(nil)
var _ containers.JSONDeserializer = (*Map)(nil)
}
// Assert Serialization implementation
var _ containers.JSONSerializer = (*Map)(nil)
var _ containers.JSONDeserializer = (*Map)(nil)
// ToJSON outputs the JSON representation of the map.
func (m *Map) ToJSON() ([]byte, error) {

@ -25,9 +25,8 @@ import (
"strings"
)
func assertMapImplementation() {
var _ maps.BidiMap = (*Map)(nil)
}
// Assert Map implementation
var _ maps.BidiMap = (*Map)(nil)
// Map holds the elements in two red-black trees.
type Map struct {

@ -9,9 +9,8 @@ import (
rbt "github.com/emirpasic/gods/trees/redblacktree"
)
func assertEnumerableImplementation() {
var _ containers.EnumerableWithKey = (*Map)(nil)
}
// Assert Enumerable implementation
var _ containers.EnumerableWithKey = (*Map)(nil)
// Each calls the given function once for each element, passing that element's key and value.
func (m *Map) Each(f func(key interface{}, value interface{})) {

@ -9,9 +9,8 @@ import (
rbt "github.com/emirpasic/gods/trees/redblacktree"
)
func assertIteratorImplementation() {
var _ containers.ReverseIteratorWithKey = (*Iterator)(nil)
}
// Assert Iterator implementation
var _ containers.ReverseIteratorWithKey = (*Iterator)(nil)
// Iterator holding the iterator's state
type Iterator struct {

@ -8,10 +8,9 @@ import (
"github.com/emirpasic/gods/containers"
)
func assertSerializationImplementation() {
var _ containers.JSONSerializer = (*Map)(nil)
var _ containers.JSONDeserializer = (*Map)(nil)
}
// Assert Serialization implementation
var _ containers.JSONSerializer = (*Map)(nil)
var _ containers.JSONDeserializer = (*Map)(nil)
// ToJSON outputs the JSON representation of the map.
func (m *Map) ToJSON() ([]byte, error) {

@ -19,9 +19,8 @@ import (
"strings"
)
func assertMapImplementation() {
var _ maps.Map = (*Map)(nil)
}
// Assert Map implementation
var _ maps.Map = (*Map)(nil)
// Map holds the elements in a red-black tree
type Map struct {

@ -15,9 +15,8 @@ import (
"strings"
)
func assertSetImplementation() {
var _ sets.Set = (*Set)(nil)
}
// Assert Set implementation
var _ sets.Set = (*Set)(nil)
// Set holds elements in go's native map
type Set struct {

@ -9,10 +9,9 @@ import (
"github.com/emirpasic/gods/containers"
)
func assertSerializationImplementation() {
var _ containers.JSONSerializer = (*Set)(nil)
var _ containers.JSONDeserializer = (*Set)(nil)
}
// Assert Serialization implementation
var _ containers.JSONSerializer = (*Set)(nil)
var _ containers.JSONDeserializer = (*Set)(nil)
// ToJSON outputs the JSON representation of the set.
func (set *Set) ToJSON() ([]byte, error) {

@ -6,9 +6,8 @@ package linkedhashset
import "github.com/emirpasic/gods/containers"
func assertEnumerableImplementation() {
var _ containers.EnumerableWithIndex = (*Set)(nil)
}
// Assert Enumerable implementation
var _ containers.EnumerableWithIndex = (*Set)(nil)
// Each calls the given function once for each element, passing that element's index and value.
func (set *Set) Each(f func(index int, value interface{})) {

@ -9,9 +9,8 @@ import (
"github.com/emirpasic/gods/lists/doublylinkedlist"
)
func assertIteratorImplementation() {
var _ containers.ReverseIteratorWithIndex = (*Iterator)(nil)
}
// Assert Iterator implementation
var _ containers.ReverseIteratorWithIndex = (*Iterator)(nil)
// Iterator holding the iterator's state
type Iterator struct {

@ -20,9 +20,8 @@ import (
"strings"
)
func assertSetImplementation() {
var _ sets.Set = (*Set)(nil)
}
// Assert Set implementation
var _ sets.Set = (*Set)(nil)
// Set holds elements in go's native map
type Set struct {

@ -9,10 +9,9 @@ import (
"github.com/emirpasic/gods/containers"
)
func assertSerializationImplementation() {
var _ containers.JSONSerializer = (*Set)(nil)
var _ containers.JSONDeserializer = (*Set)(nil)
}
// Assert Serialization implementation
var _ containers.JSONSerializer = (*Set)(nil)
var _ containers.JSONDeserializer = (*Set)(nil)
// ToJSON outputs the JSON representation of the set.
func (set *Set) ToJSON() ([]byte, error) {

@ -9,9 +9,8 @@ import (
rbt "github.com/emirpasic/gods/trees/redblacktree"
)
func assertEnumerableImplementation() {
var _ containers.EnumerableWithIndex = (*Set)(nil)
}
// Assert Enumerable implementation
var _ containers.EnumerableWithIndex = (*Set)(nil)
// Each calls the given function once for each element, passing that element's index and value.
func (set *Set) Each(f func(index int, value interface{})) {

@ -9,9 +9,8 @@ import (
rbt "github.com/emirpasic/gods/trees/redblacktree"
)
func assertIteratorImplementation() {
var _ containers.ReverseIteratorWithIndex = (*Iterator)(nil)
}
// Assert Iterator implementation
var _ containers.ReverseIteratorWithIndex = (*Iterator)(nil)
// Iterator returns a stateful iterator whose values can be fetched by an index.
type Iterator struct {

@ -9,10 +9,9 @@ import (
"github.com/emirpasic/gods/containers"
)
func assertSerializationImplementation() {
var _ containers.JSONSerializer = (*Set)(nil)
var _ containers.JSONDeserializer = (*Set)(nil)
}
// Assert Serialization implementation
var _ containers.JSONSerializer = (*Set)(nil)
var _ containers.JSONDeserializer = (*Set)(nil)
// ToJSON outputs the JSON representation of the set.
func (set *Set) ToJSON() ([]byte, error) {

@ -18,9 +18,8 @@ import (
"strings"
)
func assertSetImplementation() {
var _ sets.Set = (*Set)(nil)
}
// Assert Set implementation
var _ sets.Set = (*Set)(nil)
// Set holds elements in a red-black tree
type Set struct {

@ -16,9 +16,8 @@ import (
"strings"
)
func assertStackImplementation() {
var _ stacks.Stack = (*Stack)(nil)
}
// Assert Stack implementation
var _ stacks.Stack = (*Stack)(nil)
// Stack holds elements in an array-list
type Stack struct {

@ -6,9 +6,8 @@ package arraystack
import "github.com/emirpasic/gods/containers"
func assertIteratorImplementation() {
var _ containers.ReverseIteratorWithIndex = (*Iterator)(nil)
}
// Assert Iterator implementation
var _ containers.ReverseIteratorWithIndex = (*Iterator)(nil)
// Iterator returns a stateful iterator whose values can be fetched by an index.
type Iterator struct {

@ -8,10 +8,9 @@ import (
"github.com/emirpasic/gods/containers"
)
func assertSerializationImplementation() {
var _ containers.JSONSerializer = (*Stack)(nil)
var _ containers.JSONDeserializer = (*Stack)(nil)
}
// Assert Serialization implementation
var _ containers.JSONSerializer = (*Stack)(nil)
var _ containers.JSONDeserializer = (*Stack)(nil)
// ToJSON outputs the JSON representation of the stack.
func (stack *Stack) ToJSON() ([]byte, error) {

@ -6,9 +6,8 @@ package linkedliststack
import "github.com/emirpasic/gods/containers"
func assertIteratorImplementation() {
var _ containers.IteratorWithIndex = (*Iterator)(nil)
}
// Assert Iterator implementation
var _ containers.IteratorWithIndex = (*Iterator)(nil)
// Iterator returns a stateful iterator whose values can be fetched by an index.
type Iterator struct {

@ -16,9 +16,8 @@ import (
"strings"
)
func assertStackImplementation() {
var _ stacks.Stack = (*Stack)(nil)
}
// Assert Stack implementation
var _ stacks.Stack = (*Stack)(nil)
// Stack holds elements in a singly-linked-list
type Stack struct {

@ -8,10 +8,9 @@ import (
"github.com/emirpasic/gods/containers"
)
func assertSerializationImplementation() {
var _ containers.JSONSerializer = (*Stack)(nil)
var _ containers.JSONDeserializer = (*Stack)(nil)
}
// Assert Serialization implementation
var _ containers.JSONSerializer = (*Stack)(nil)
var _ containers.JSONDeserializer = (*Stack)(nil)
// ToJSON outputs the JSON representation of the stack.
func (stack *Stack) ToJSON() ([]byte, error) {

@ -15,9 +15,8 @@ import (
"github.com/emirpasic/gods/utils"
)
func assertTreeImplementation() {
var _ trees.Tree = new(Tree)
}
// Assert Tree implementation
var _ trees.Tree = new(Tree)
// Tree holds elements of the AVL tree.
type Tree struct {

@ -6,9 +6,8 @@ package avltree
import "github.com/emirpasic/gods/containers"
func assertIteratorImplementation() {
var _ containers.ReverseIteratorWithKey = (*Iterator)(nil)
}
// Assert Iterator implementation
var _ containers.ReverseIteratorWithKey = (*Iterator)(nil)
// Iterator holding the iterator's state
type Iterator struct {

@ -10,10 +10,9 @@ import (
"github.com/emirpasic/gods/utils"
)
func assertSerializationImplementation() {
var _ containers.JSONSerializer = (*Tree)(nil)
var _ containers.JSONDeserializer = (*Tree)(nil)
}
// Assert Serialization implementation
var _ containers.JSONSerializer = (*Tree)(nil)
var _ containers.JSONDeserializer = (*Tree)(nil)
// ToJSON outputs the JSON representation of the tree.
func (tree *Tree) ToJSON() ([]byte, error) {

@ -19,9 +19,8 @@ import (
"strings"
)
func assertTreeImplementation() {
var _ trees.Tree = (*Heap)(nil)
}
// Assert Tree implementation
var _ trees.Tree = (*Heap)(nil)
// Heap holds elements in an array-list
type Heap struct {

@ -6,9 +6,8 @@ package binaryheap
import "github.com/emirpasic/gods/containers"
func assertIteratorImplementation() {
var _ containers.ReverseIteratorWithIndex = (*Iterator)(nil)
}
// Assert Iterator implementation
var _ containers.ReverseIteratorWithIndex = (*Iterator)(nil)
// Iterator returns a stateful iterator whose values can be fetched by an index.
type Iterator struct {

@ -8,10 +8,9 @@ import (
"github.com/emirpasic/gods/containers"
)
func assertSerializationImplementation() {
var _ containers.JSONSerializer = (*Heap)(nil)
var _ containers.JSONDeserializer = (*Heap)(nil)
}
// Assert Serialization implementation
var _ containers.JSONSerializer = (*Heap)(nil)
var _ containers.JSONDeserializer = (*Heap)(nil)
// ToJSON outputs the JSON representation of the heap.
func (heap *Heap) ToJSON() ([]byte, error) {

@ -24,9 +24,8 @@ import (
"strings"
)
func assertTreeImplementation() {
var _ trees.Tree = (*Tree)(nil)
}
// Assert Tree implementation
var _ trees.Tree = (*Tree)(nil)
// Tree holds elements of the B-tree
type Tree struct {

@ -6,9 +6,8 @@ package btree
import "github.com/emirpasic/gods/containers"
func assertIteratorImplementation() {
var _ containers.ReverseIteratorWithKey = (*Iterator)(nil)
}
// Assert Iterator implementation
var _ containers.ReverseIteratorWithKey = (*Iterator)(nil)
// Iterator holding the iterator's state
type Iterator struct {

@ -10,10 +10,9 @@ import (
"github.com/emirpasic/gods/utils"
)
func assertSerializationImplementation() {
var _ containers.JSONSerializer = (*Tree)(nil)
var _ containers.JSONDeserializer = (*Tree)(nil)
}
// Assert Serialization implementation
var _ containers.JSONSerializer = (*Tree)(nil)
var _ containers.JSONDeserializer = (*Tree)(nil)
// ToJSON outputs the JSON representation of the tree.
func (tree *Tree) ToJSON() ([]byte, error) {

@ -6,9 +6,8 @@ package redblacktree
import "github.com/emirpasic/gods/containers"
func assertIteratorImplementation() {
var _ containers.ReverseIteratorWithKey = (*Iterator)(nil)
}
// Assert Iterator implementation
var _ containers.ReverseIteratorWithKey = (*Iterator)(nil)
// Iterator holding the iterator's state
type Iterator struct {

@ -17,9 +17,8 @@ import (
"github.com/emirpasic/gods/utils"
)
func assertTreeImplementation() {
var _ trees.Tree = (*Tree)(nil)
}
// Assert Tree implementation
var _ trees.Tree = (*Tree)(nil)
type color bool

@ -10,10 +10,9 @@ import (
"github.com/emirpasic/gods/utils"
)
func assertSerializationImplementation() {
var _ containers.JSONSerializer = (*Tree)(nil)
var _ containers.JSONDeserializer = (*Tree)(nil)
}
// Assert Serialization implementation
var _ containers.JSONSerializer = (*Tree)(nil)
var _ containers.JSONDeserializer = (*Tree)(nil)
// ToJSON outputs the JSON representation of the tree.
func (tree *Tree) ToJSON() ([]byte, error) {

Loading…
Cancel
Save