// Copyright 2019, OpenCensus Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package trace

import (
	"github.com/hashicorp/golang-lru/simplelru"
)

type lruMap struct {
	simpleLruMap *simplelru.LRU
	droppedCount int
}

func newLruMap(size int) *lruMap {
	lm := &lruMap{}
	lm.simpleLruMap, _ = simplelru.NewLRU(size, nil)
	return lm
}

func (lm *lruMap) add(key, value interface{}) {
	evicted := lm.simpleLruMap.Add(key, value)
	if evicted {
		lm.droppedCount++
	}
}
