Convert IEnumerable to HashSet : IEnumerable « Collections Data Structure « C# / C Sharp






Convert IEnumerable to HashSet

  
/*
    This file is part of Sunlit World Scheme
    http://swscheme.codeplex.com/
    Copyright (c) 2010 by Edward Kiser (edkiser@gmail.com)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ExprObjModel
{
    public static partial class Utils
    {
        public static HashSet<T> ToHashSet<T>(this IEnumerable<T> list)
        {
            HashSet<T> result = new HashSet<T>();
            result.UnionWith(list);
            return result;
        }


    }
}

   
    
  








Related examples in the same category

1.Determines whether the specified collection is null or empty.
2.Determines whether the collection contains the specified element
3.Determines whether the collection contains all the elements in the specified collection.
4.Aggregate IEnumerable
5.Convert IEnumerable To DataTable
6.Convert IEnumerable by Func
7.Split IEnumerable
8.Shuffle IEnumerable
9.For each IEnumerable
10.Sleep before yield each element in IEnumerable
11.Add WhereIf to IEnumerable
12.Add OrderBy to IEnumerable
13.Add Repeat extension to IEnumerable
14.Yield element in IEnumerable until Predicate
15.IEnumerable extension for get second and third element
16.Simple function to determine if an item is an IEnumerable
17.Object class extension for IEnumerable, IComparable and where
18.Output DataTable and IEnumerable to console
19.Convert IEnumerable to String
20.Convert XmlNodeList to IEnumerable
21.Returns the first element contained in both, source and candidates.
22.Given a range (start,end) and a number of steps, will yield that a number for each step
23.Compares two sequences.
24.Empty Enumerable/Enumerator
25.CharEnumerator supports iterating over a String and reading its individual characters.
26.IEnumerable interface exposes the enumerator, which supports a simple iteration over a non-generic collection.
27.IEnumerator interface supports a simple iteration over a nongeneric collection.
28.Convert IEnumerable to ObservableCollection
29.IEnumerable To Comma String
30.Do all for IEnumerable and Action
31.Convert IEnumerable to IEnumerable
32.Filter IEnumerable with Predicate
33.Join IEnumerable
34.Mode value for IEnumerable
35.Build Statistics function on to IEnumerable
36.Compare two IEnumerable
37.Concatenate IEnumerable to String
38.Singleton IEnumerable
39.Convert IEnumerable To ReadOnlyCollection
40.Performs the specified action on each element of the IEnumerable
41.Creates a list by applying a delegate to pairs of items in the IEnumerable
42.Returns true if there are enough items in the IEnumerable
43.Returns true if there are no more than a set number of items in the IEnumerable
44.Groups items into same size lots.