counter

package
v0.0.0-...-a8a07f9 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

ex7.1 provides line and word counters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LineCounter

type LineCounter struct {
	// contains filtered or unexported fields
}

func (*LineCounter) N

func (c *LineCounter) N() int

func (*LineCounter) String

func (c *LineCounter) String() string

func (*LineCounter) Write

func (c *LineCounter) Write(p []byte) (n int, err error)

type WordCounter

type WordCounter struct {
	// contains filtered or unexported fields
}

func (*WordCounter) N

func (c *WordCounter) N() int

func (*WordCounter) String

func (c *WordCounter) String() string

func (*WordCounter) Write

func (c *WordCounter) Write(p []byte) (n int, err error)

A !IsSpace() -> IsSpace() transition is counted as a word.

I couldn't figure out how to use bufio.ScanWords without either double-counting words split across buffer boundaries, giving incorrect intermediate counts, or doing some really awkward buffer manipulation.

Jump to

Keyboard shortcuts

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