Skip to content

Commit cfca6cc

Browse files
committed
Cast each element of CastingSetAdapter instead of casting the whole enumerable
1 parent 7326f97 commit cfca6cc

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

src/Lucene.Net/Support/CastingSetAdapter.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
using System.Collections;
1+
using System.Collections;
22
using System.Collections.Generic;
3+
using System.Linq;
34

45
namespace Lucene.Net.Support
56
{
@@ -43,25 +44,25 @@ public CastingSetAdapter(ISet<T> set)
4344

4445
void ICollection<U>.Add(U item) => set.Add(((T)item)!);
4546

46-
public void UnionWith(IEnumerable<U> other) => set.UnionWith((IEnumerable<T>)other);
47+
public void UnionWith(IEnumerable<U> other) => set.UnionWith(other.Cast<T>());
4748

48-
public void IntersectWith(IEnumerable<U> other) => set.IntersectWith((IEnumerable<T>)other);
49+
public void IntersectWith(IEnumerable<U> other) => set.IntersectWith(other.Cast<T>());
4950

50-
public void ExceptWith(IEnumerable<U> other) => set.ExceptWith((IEnumerable<T>)other);
51+
public void ExceptWith(IEnumerable<U> other) => set.ExceptWith(other.Cast<T>());
5152

52-
public void SymmetricExceptWith(IEnumerable<U> other) => set.SymmetricExceptWith((IEnumerable<T>)other);
53+
public void SymmetricExceptWith(IEnumerable<U> other) => set.SymmetricExceptWith(other.Cast<T>());
5354

54-
public bool IsSubsetOf(IEnumerable<U> other) => set.IsSubsetOf((IEnumerable<T>)other);
55+
public bool IsSubsetOf(IEnumerable<U> other) => set.IsSubsetOf(other.Cast<T>());
5556

56-
public bool IsSupersetOf(IEnumerable<U> other) => set.IsSupersetOf((IEnumerable<T>)other);
57+
public bool IsSupersetOf(IEnumerable<U> other) => set.IsSupersetOf(other.Cast<T>());
5758

58-
public bool IsProperSupersetOf(IEnumerable<U> other) => set.IsProperSupersetOf((IEnumerable<T>)other);
59+
public bool IsProperSupersetOf(IEnumerable<U> other) => set.IsProperSupersetOf(other.Cast<T>());
5960

60-
public bool IsProperSubsetOf(IEnumerable<U> other) => set.IsProperSubsetOf((IEnumerable<T>)other);
61+
public bool IsProperSubsetOf(IEnumerable<U> other) => set.IsProperSubsetOf(other.Cast<T>());
6162

62-
public bool Overlaps(IEnumerable<U> other) => set.Overlaps((IEnumerable<T>)other);
63+
public bool Overlaps(IEnumerable<U> other) => set.Overlaps(other.Cast<T>());
6364

64-
public bool SetEquals(IEnumerable<U> other) => set.SetEquals((IEnumerable<T>)other);
65+
public bool SetEquals(IEnumerable<U> other) => set.SetEquals(other.Cast<T>());
6566

6667
bool ISet<U>.Add(U item) => set.Add((T)item);
6768

0 commit comments

Comments
 (0)