package otherutils

type FilterInt64 struct {
	allItem map[int64][]interface{}
}

func (m *FilterInt64) Add(id int64) {
	if m.allItem == nil {
		m.allItem = make(map[int64][]interface{})
	}
	m.allItem[id] = nil //make([]interface{}, 0)
}

func (m *FilterInt64) Remove(id int64) []interface{} {
	v, ok := m.allItem[id]
	if ok {
		delete(m.allItem, id)
		return v
	}
	return nil
}

func (m *FilterInt64) IsExist(id int64) bool {
	if _, ok := m.allItem[id]; ok {
		return true
	}
	return false
}

func (m *FilterInt64) AppendTask(id int64, task interface{}) {
	v, ok := m.allItem[id]
	if ok {
		v = append(v, task)
		m.allItem[id] = v
	}
}

type FilterString struct {
	allItem map[string][]interface{}
}

func (m *FilterString) Add(id string) {
	if m.allItem == nil {
		m.allItem = make(map[string][]interface{})
	}
	m.allItem[id] = nil //make([]interface{}, 0)
}

func (m *FilterString) Remove(id string) []interface{} {
	v, ok := m.allItem[id]
	if ok {
		delete(m.allItem, id)
		return v
	}
	return nil
}

func (m *FilterString) IsExist(id string) bool {
	if _, ok := m.allItem[id]; ok {
		return true
	}
	return false
}

func (m *FilterString) AppendTask(id string, task interface{}) {
	v, ok := m.allItem[id]
	if ok {
		v = append(v, task)
		m.allItem[id] = v
	}
}
