/// <summary> /// Initializes a new instance of the <see cref="TextMatchHelper"/> class. /// </summary> /// <param name="matches">The matches to match against.</param> /// <exception cref="System.ArgumentNullException"></exception> public TextMatchHelper(HashSet <string> matches) { if (matches == null) { throw new ArgumentNullException(nameof(matches)); } var list = new List <string>(matches); root = new CharNode(); listCache = new ListCache(); BuildMap(root, 0, list); listCache.Clear(); }
//--------------------------------------------------------------------- // 从Map中随机获取数据 Task <List <byte[]> > IGrainDCacheMap.getFromMapRandom(int count) { ListCache.Clear(); ListCacheRandom.Clear(); ListCache.AddRange(MapCache.Values); if (ListCache.Count > count) { for (int i = 0; i < count; i++) { ListCacheRandom.Add(ListCache[Random.Next(0, ListCache.Count)]); } } else { ListCacheRandom.AddRange(ListCache); } ListCache.Clear(); return(Task.FromResult(ListCacheRandom)); }