11// Copyright (c) Microsoft Corporation. All rights reserved.
22// Licensed under the MIT License. See LICENSE in the project root for license information.
33
4- using HoloToolkit . Diagnostics ;
54using System ;
65using System . Collections ;
76using System . Collections . Generic ;
7+ using UnityEngine ;
88
99namespace HoloToolkit . Unity
1010{
11+ /// <summary>
12+ /// A wrapper for <see cref="HashSet{T}"/> that doesn't allow modification of the set. This is
13+ /// useful for handing out references to a set that is going to be modified internally, without
14+ /// giving external consumers the opportunity to accidentally modify the set.
15+ /// </summary>
1116 public class ReadOnlyHashSet < TElement > :
1217 ICollection < TElement > ,
1318 IEnumerable < TElement > ,
@@ -17,7 +22,7 @@ public class ReadOnlyHashSet<TElement> :
1722
1823 public ReadOnlyHashSet ( HashSet < TElement > underlyingSet )
1924 {
20- Assert . IsTrue ( DiagnosticContext . Create ( ) , underlyingSet != null , "underlyingSet cannot be null." ) ;
25+ Debug . Assert ( underlyingSet != null , "underlyingSet cannot be null." ) ;
2126
2227 this . underlyingSet = underlyingSet ;
2328 }
@@ -27,17 +32,17 @@ public int Count
2732 get { return underlyingSet . Count ; }
2833 }
2934
30- public bool IsReadOnly
35+ bool ICollection < TElement > . IsReadOnly
3136 {
3237 get { return true ; }
3338 }
3439
35- public void Add ( TElement item )
40+ void ICollection < TElement > . Add ( TElement item )
3641 {
3742 throw NewWriteDeniedException ( ) ;
3843 }
3944
40- public void Clear ( )
45+ void ICollection < TElement > . Clear ( )
4146 {
4247 throw NewWriteDeniedException ( ) ;
4348 }
@@ -57,7 +62,7 @@ public IEnumerator<TElement> GetEnumerator()
5762 return underlyingSet . GetEnumerator ( ) ;
5863 }
5964
60- public bool Remove ( TElement item )
65+ bool ICollection < TElement > . Remove ( TElement item )
6166 {
6267 throw NewWriteDeniedException ( ) ;
6368 }
0 commit comments