2024-12-10 21:42:26 +00:00
|
|
|
package two
|
|
|
|
|
2024-12-19 12:54:40 +00:00
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
type kind int
|
|
|
|
|
|
|
|
const (
|
|
|
|
kindOfFile kind = iota
|
|
|
|
kindOfEmpty
|
|
|
|
)
|
2024-12-10 21:42:26 +00:00
|
|
|
|
|
|
|
type block struct {
|
2024-12-19 12:54:40 +00:00
|
|
|
kind kind
|
|
|
|
id int
|
|
|
|
start int
|
|
|
|
length int
|
|
|
|
value int
|
2024-12-10 21:42:26 +00:00
|
|
|
}
|
|
|
|
|
2024-12-19 12:54:40 +00:00
|
|
|
func newBlock(kind kind, id, start, length, value int) *block {
|
|
|
|
return &block{kind, id, start, length, value}
|
2024-12-10 21:42:26 +00:00
|
|
|
}
|
|
|
|
|
2024-12-19 12:54:40 +00:00
|
|
|
func (b *block) String() string {
|
|
|
|
var kindStr string
|
|
|
|
switch b.kind {
|
|
|
|
case kindOfFile:
|
|
|
|
kindStr = "file"
|
|
|
|
case kindOfEmpty:
|
|
|
|
kindStr = "empty"
|
|
|
|
}
|
|
|
|
return fmt.Sprintf("kind: %s id: %d start: %d length: %d", kindStr, b.id, b.start, b.length)
|
2024-12-10 21:42:26 +00:00
|
|
|
}
|