Jens Geyer | aa0c8b3 | 2019-01-28 23:27:45 +0100 | [diff] [blame^] | 1 | // Licensed to the Apache Software Foundation(ASF) under one |
| 2 | // or more contributor license agreements.See the NOTICE file |
| 3 | // distributed with this work for additional information |
| 4 | // regarding copyright ownership.The ASF licenses this file |
| 5 | // to you under the Apache License, Version 2.0 (the |
| 6 | // "License"); you may not use this file except in compliance |
| 7 | // with the License. You may obtain a copy of the License at |
| 8 | // |
| 9 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | // |
| 11 | // Unless required by applicable law or agreed to in writing, |
| 12 | // software distributed under the License is distributed on an |
| 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | // KIND, either express or implied. See the License for the |
| 15 | // specific language governing permissions and limitations |
| 16 | // under the License. |
| 17 | |
| 18 | using System.Collections; |
| 19 | using System.Collections.Generic; |
| 20 | |
| 21 | namespace Thrift.Collections |
| 22 | { |
| 23 | // ReSharper disable once InconsistentNaming |
| 24 | public class THashSet<T> : ICollection<T> |
| 25 | { |
| 26 | private readonly HashSet<T> _set = new HashSet<T>(); |
| 27 | |
| 28 | public int Count => _set.Count; |
| 29 | |
| 30 | public bool IsReadOnly => false; |
| 31 | |
| 32 | public void Add(T item) |
| 33 | { |
| 34 | _set.Add(item); |
| 35 | } |
| 36 | |
| 37 | public void Clear() |
| 38 | { |
| 39 | _set.Clear(); |
| 40 | } |
| 41 | |
| 42 | public bool Contains(T item) |
| 43 | { |
| 44 | return _set.Contains(item); |
| 45 | } |
| 46 | |
| 47 | public void CopyTo(T[] array, int arrayIndex) |
| 48 | { |
| 49 | _set.CopyTo(array, arrayIndex); |
| 50 | } |
| 51 | |
| 52 | public IEnumerator GetEnumerator() |
| 53 | { |
| 54 | return _set.GetEnumerator(); |
| 55 | } |
| 56 | |
| 57 | IEnumerator<T> IEnumerable<T>.GetEnumerator() |
| 58 | { |
| 59 | return ((IEnumerable<T>) _set).GetEnumerator(); |
| 60 | } |
| 61 | |
| 62 | public bool Remove(T item) |
| 63 | { |
| 64 | return _set.Remove(item); |
| 65 | } |
| 66 | } |
| 67 | } |