list

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package list provides implementation to get and print formatted linked list.

Example:

import "github.com/shivamMg/ppds/list"

// a linked list node. implements list.Node.
type Node struct {
	data int
	next *Node
}

func (n *Node) Data() interface{} {
	return strconv.Itoa(n.data)
}

func (n *Node) Next() list.Node {
	return n.next
}

// n1 := Node{data: 11}
// n2 := Node{12, &n1}
// n3 := Node{13, &n2}
// list.Print(&n3)

Index

Constants

View Source
const (
	BoxVer       = "│"
	BoxHor       = "─"
	BoxDownLeft  = "┐"
	BoxDownRight = "┌"
	BoxUpLeft    = "┘"
	BoxUpRight   = "└"
	BoxVerLeft   = "┤"
	BoxVerRight  = "├"
)

Variables

This section is empty.

Functions

func Print

func Print(head Node)

Print prints the formatted linked list to standard output.

func Sprint

func Sprint(head Node) (s string)

Sprint returns the formatted linked list.

Types

type Node

type Node interface {
	// Data must return a value representing the node.
	Data() interface{}
	// Next must return a pointer to the next node. The last element
	// of the list must return a nil pointer.
	Next() Node
}

Node represents a linked list node.

Jump to

Keyboard shortcuts

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