Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / Microsoft / Scripting / Compiler / Set.cs / 1305376 / Set.cs
/* **************************************************************************** * * Copyright (c) Microsoft Corporation. * * This source code is subject to terms and conditions of the Microsoft Public License. A * copy of the license can be found in the License.html file at the root of this distribution. If * you cannot locate the Microsoft Public License, please send an email to * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound * by the terms of the Microsoft Public License. * * You must not remove this notice, or any other, from this software. * * * ***************************************************************************/ using System.Collections; using System.Collections.Generic; // Note: can't move to Utils because name conflicts with System.Linq.Set namespace System.Linq.Expressions { ////// A simple hashset, built on Dictionary{K, V} /// internal sealed class Set: ICollection { private readonly Dictionary _data; internal Set() { _data = new Dictionary (); } internal Set(IEqualityComparer comparer) { _data = new Dictionary (comparer); } internal Set(IList list) { _data = new Dictionary (list.Count); foreach (T t in list) { Add(t); } } internal Set(IEnumerable list) { _data = new Dictionary (); foreach (T t in list) { Add(t); } } internal Set(int capacity) { _data = new Dictionary (capacity); } public void Add(T item) { _data[item] = null; } public void Clear() { _data.Clear(); } public bool Contains(T item) { return _data.ContainsKey(item); } public void CopyTo(T[] array, int arrayIndex) { _data.Keys.CopyTo(array, arrayIndex); } public int Count { get { return _data.Count; } } public bool IsReadOnly { get { return false; } } public bool Remove(T item) { return _data.Remove(item); } public IEnumerator GetEnumerator() { return _data.Keys.GetEnumerator(); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return _data.Keys.GetEnumerator(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PassportAuthentication.cs
- FtpCachePolicyElement.cs
- Empty.cs
- DiscreteKeyFrames.cs
- FixedTextSelectionProcessor.cs
- ScrollBarAutomationPeer.cs
- ModifierKeysValueSerializer.cs
- RelationshipEnd.cs
- WorkflowRuntimeSection.cs
- OutOfProcStateClientManager.cs
- CqlParserHelpers.cs
- SymmetricAlgorithm.cs
- ReturnType.cs
- BufferedWebEventProvider.cs
- SynthesizerStateChangedEventArgs.cs
- PropertyOverridesTypeEditor.cs
- BaseProcessor.cs
- UndoUnit.cs
- UnsafeNativeMethods.cs
- ClientWindowsAuthenticationMembershipProvider.cs
- PingReply.cs
- MexTcpBindingCollectionElement.cs
- CustomValidator.cs
- SqlDeflator.cs
- XmlnsCompatibleWithAttribute.cs
- FileDialogCustomPlaces.cs
- TextBoxRenderer.cs
- GridSplitter.cs
- XsdCachingReader.cs
- DoubleMinMaxAggregationOperator.cs
- GridViewColumnCollectionChangedEventArgs.cs
- CryptoProvider.cs
- OutputCacheSection.cs
- ApplicationInfo.cs
- GenericsInstances.cs
- ObjectNavigationPropertyMapping.cs
- RelationshipNavigation.cs
- DbProviderSpecificTypePropertyAttribute.cs
- CacheEntry.cs
- FileDialog_Vista.cs
- SafeFileHandle.cs
- VerificationAttribute.cs
- TypeTypeConverter.cs
- SymLanguageVendor.cs
- RequestContext.cs
- Module.cs
- HtmlElement.cs
- SystemIPAddressInformation.cs
- ResourceProperty.cs
- Attributes.cs
- TransformPattern.cs
- RequestCachePolicyConverter.cs
- NetworkInterface.cs
- ConnectionPool.cs
- InheritanceAttribute.cs
- BaseCollection.cs
- _Win32.cs
- DataException.cs
- formatter.cs
- TextSelectionHelper.cs
- GifBitmapEncoder.cs
- TraceLog.cs
- CaseStatement.cs
- NonVisualControlAttribute.cs
- FixedTextBuilder.cs
- PropertyOverridesDialog.cs
- QuerySubExprEliminator.cs
- ColorTransformHelper.cs
- MouseDevice.cs
- ProjectionCamera.cs
- CommunicationObject.cs
- RtfToXamlLexer.cs
- PathFigureCollection.cs
- CompiledXpathExpr.cs
- SqlMethodAttribute.cs
- TextPattern.cs
- DataGridRow.cs
- Stroke2.cs
- WebPartEditVerb.cs
- SegmentInfo.cs
- CommandTreeTypeHelper.cs
- DataServiceException.cs
- Registration.cs
- Solver.cs
- RadioButton.cs
- FrameworkContentElement.cs
- ActivityMarkupSerializer.cs
- ToolStripDropDownClosedEventArgs.cs
- DispatcherObject.cs
- Terminate.cs
- dsa.cs
- SvcMapFile.cs
- BaseResourcesBuildProvider.cs
- UIElementPropertyUndoUnit.cs
- TreeViewEvent.cs
- ReflectionTypeLoadException.cs
- KeyedCollection.cs
- XpsThumbnail.cs
- KnownTypes.cs
- GeneralTransform.cs