<commit_before>package frame

import (
	"bytes"
	"errors"
)

type APICSequencer interface {
	Framer

	AddPicture(PictureFramer) error
	Picture(picType string) (PictureFramer, error)
}

// APICSequence stores several APICs and implements interface Framer.
// Key for APICSequnce is a key for PictureType array,
// so there is only one picture with the same picture type
type APICSequence struct {
	sequence map[int]PictureFramer
}

func NewAPICSequence() *APICSequence {
	return &APICSequence{
		sequence: make(map[int]PictureFramer),
	}
}

func (as APICSequence) Form() []byte {
	b := bytesBufPool.Get().(*bytes.Buffer)
	b.Reset()
	for _, pf := range as.sequence {
		frame := pf.Form()
		b.Write(frame)
	}
	bytesBufPool.Put(b)
	return b.Bytes()
}

//TODO: if PictureType not found
func (as *APICSequence) AddPicture(pic PictureFramer) error {
	for k, v := range PictureTypes {
		if v == pic.PictureType() {
			as.sequence[k] = pic
			return nil
		}
	}
	return errors.New("Unsupported picture type")
}

func (as APICSequence) Picture(picType string) (PictureFramer, error) {
	for k, v := range PictureTypes {
		if v == picType {
			return as.sequence[k], nil
		}
	}
	return &PictureFrame{}, errors.New("Unsupported picture type")
}<commit_msg>Delete TODO in APICSequence<commit_after>package frame

import (
	"bytes"
	"errors"
)

type APICSequencer interface {
	Framer

	AddPicture(PictureFramer) error
	Picture(picType string) (PictureFramer, error)
}

// APICSequence stores several APICs and implements interface Framer.
// Key for APICSequnce is a key for PictureType array,
// so there is only one picture with the same picture type
type APICSequence struct {
	sequence map[int]PictureFramer
}

func NewAPICSequence() *APICSequence {
	return &APICSequence{
		sequence: make(map[int]PictureFramer),
	}
}

func (as APICSequence) Form() []byte {
	b := bytesBufPool.Get().(*bytes.Buffer)
	b.Reset()
	for _, pf := range as.sequence {
		frame := pf.Form()
		b.Write(frame)
	}
	bytesBufPool.Put(b)
	return b.Bytes()
}

func (as *APICSequence) AddPicture(pic PictureFramer) error {
	for k, v := range PictureTypes {
		if v == pic.PictureType() {
			as.sequence[k] = pic
			return nil
		}
	}
	return errors.New("Unsupported picture type")
}

func (as APICSequence) Picture(picType string) (PictureFramer, error) {
	for k, v := range PictureTypes {
		if v == picType {
			return as.sequence[k], nil
		}
	}
	return &PictureFrame{}, errors.New("Unsupported picture type")
}
{'fraction_non_alphanumeric': 0.118052738336714, 'fraction_numerical': 0.0, 'mean_word_length': 4.326133909287257, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7353868', 'n_tokens_mistral': 884, 'n_tokens_neox': 836, 'n_words': 244}