1
using System.Collections.Generic;
2
using Libplanet.Store.Trie;
3

4
namespace Libplanet.Tests.Store.Trie
5
{
6
    public class MemoryKeyValueStore : IKeyValueStore
7
    {
8
        public MemoryKeyValueStore()
9 1
            : this(new Dictionary<byte[], byte[]>())
10 1
        {
11 1
        }
12

13 1
        public MemoryKeyValueStore(Dictionary<byte[], byte[]> dictionary)
14 1
        {
15 1
            Dictionary = new Dictionary<byte[], byte[]>(dictionary, new BytesEqualityComparer());
16 1
        }
17

18 1
        private Dictionary<byte[], byte[]> Dictionary { get; }
19

20
        public byte[] Get(byte[] key)
21 1
        {
22 1
            return Dictionary[key];
23 1
        }
24

25
        public void Set(byte[] key, byte[] value)
26 1
        {
27 1
            Dictionary[key] = value;
28 1
        }
29

30
        public void Delete(byte[] key)
31 0
        {
32 0
            Dictionary.Remove(key);
33 0
        }
34

35
        public bool Exists(byte[] key)
36 1
        {
37 1
            return Dictionary.ContainsKey(key);
38 1
        }
39

40 1
        public IEnumerable<byte[]> ListKeys() => Dictionary.Keys;
41
    }
42
}

Read our documentation on viewing source code .

Loading