algo-go

command module
v0.0.0-...-67c09b2 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: BSD-3-Clause Imports: 2 Imported by: 0

README

使用

package main
import (
"github.com/algo-go/hashing"
"fmt"
)

func main (){

  nodeWeight := make(map[string]int)
    for i := 0; i < 10; i++ {
		si := fmt.Sprintf("%d", i)
    nodeWeight["211.104.10."+si] = 2
	}
    vitualSpots := 0
    hash := hashring.NewHashRing(vitualSpots)


    //add nodes
    hash.AddNodes(nodeWeight)

    // for _, v := range hash.GetNodes(){
    // 		fmt.Println(" nodeInfo:", v)
    // 	}
    //remove node
    // hash.RemoveNode("node3")


    //add node
    // hash.AddNode("node3", 3)


    //get key's node

    ipMap := make(map[string]int, 0)
    node0 :=make(map[string]string,0)//第二个节点所有数据
    	for i := 0; i < 1000; i++ {
    		si := fmt.Sprintf("key.%d", i)
    		k := hash.GetNode(si)
        if k=="211.104.10.2" {
    		    sii := fmt.Sprintf("%d", i)
            node0["211.104.10.2-"+sii] = si
        }
    		if _, ok := ipMap[k]; ok {
    			ipMap[k] += 1
    		} else {
    			ipMap[k] = 1
    		}
    	}

       for k, v := range ipMap {
       		fmt.Println("Node IP:", k, " count:", v)
       	}
      //for k,v := range node0{
        //fmt.Println(k+"===="+v)
      //}

}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package boom implements probabilistic data structures for processing continuous, unbounded data streams.
Package boom implements probabilistic data structures for processing continuous, unbounded data streams.
Package skiplist implements skip list based maps and sets.
Package skiplist implements skip list based maps and sets.
struct
gods/containers
Package containers provides core interfaces and functions for data structures.
Package containers provides core interfaces and functions for data structures.
gods/lists
Package lists provides an abstract List interface.
Package lists provides an abstract List interface.
gods/lists/arraylist
Package arraylist implements the array list.
Package arraylist implements the array list.
gods/lists/doublylinkedlist
Package doublylinkedlist implements the doubly-linked list.
Package doublylinkedlist implements the doubly-linked list.
gods/lists/singlylinkedlist
Package singlylinkedlist implements the singly-linked list.
Package singlylinkedlist implements the singly-linked list.
gods/maps
Package maps provides an abstract Map interface.
Package maps provides an abstract Map interface.
gods/maps/hashbidimap
Package hashbidimap implements a bidirectional map backed by two hashmaps.
Package hashbidimap implements a bidirectional map backed by two hashmaps.
gods/maps/hashmap
Package hashmap implements a map backed by a hash table.
Package hashmap implements a map backed by a hash table.
gods/maps/treebidimap
Package treebidimap implements a bidirectional map backed by two red-black tree.
Package treebidimap implements a bidirectional map backed by two red-black tree.
gods/maps/treemap
Package treemap implements a map backed by red-black tree.
Package treemap implements a map backed by red-black tree.
gods/sets
Package sets provides an abstract Set interface.
Package sets provides an abstract Set interface.
gods/sets/hashset
Package hashset implements a set backed by a hash table.
Package hashset implements a set backed by a hash table.
gods/sets/treeset
Package treeset implements a tree backed by a red-black tree.
Package treeset implements a tree backed by a red-black tree.
gods/stacks
Package stacks provides an abstract Stack interface.
Package stacks provides an abstract Stack interface.
gods/stacks/arraystack
Package arraystack implements a stack backed by array list.
Package arraystack implements a stack backed by array list.
gods/stacks/linkedliststack
Package linkedliststack implements a stack backed by a singly-linked list.
Package linkedliststack implements a stack backed by a singly-linked list.
gods/trees
Package trees provides an abstract Tree interface.
Package trees provides an abstract Tree interface.
gods/trees/avltree
Package avltree implements an AVL balanced binary tree.
Package avltree implements an AVL balanced binary tree.
gods/trees/binaryheap
Package binaryheap implements a binary heap backed by array list.
Package binaryheap implements a binary heap backed by array list.
gods/trees/btree
Package btree implements a B tree.
Package btree implements a B tree.
gods/trees/redblacktree
Package redblacktree implements a red-black tree.
Package redblacktree implements a red-black tree.
gods/utils
Package utils provides common utility functions.
Package utils provides common utility functions.
Implementation of an R-Way Trie data structure.
Implementation of an R-Way Trie data structure.

Jump to

Keyboard shortcuts

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