OSDN Git Service

デバックコードを追加した
[fooeditengine/FooEditEngine.git] / Core / CacheManager.cs
1 /*
2  * Copyright (C) 2013 FooProject
3  * * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
5
6  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 
7  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
8
9 You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
10  */
11 using System;
12 using System.Collections.Generic;
13
14 namespace FooEditEngine
15 {
16     class CacheManager<TKey,TValue> : ResourceManager<TKey,TValue>
17     {
18         Queue<TKey> queque = new Queue<TKey>();
19         int maxCount = 100;
20
21         public new void Add(TKey key, TValue value)
22         {
23             base.Add(key, value);
24             if (base.Count >= maxCount)
25             {
26                 TKey overflowedKey = queque.Dequeue();
27                 base.Remove(overflowedKey);
28             }
29             queque.Enqueue(key);
30         }
31
32         public new void Clear()
33         {
34             base.Clear();
35             queque.Clear();
36         }
37     }
38 }