score:3
Accepted answer
edgelist.groupby(x=>x.source)
.where(x=>x.skip(linkcount).any())
.selectmany(x=>x)
.tolist()
score:0
dictionary<string, int> occurrence = new dictionary<string, int>();
foreach (edgedata edge in edgelist)
{
if (occurrence.containskey(edge.source))
occurrence[edge.source] += 1;
else
occurrence[edge.source] = 1;
}
int counter = 0;
while(counter < edgelist.count)
{
if (occurrence[edgelist[counter].source] < linkcount)
edgelist.removeat(counter);
else
counter++;
}
score:1
ienumerable<edgedata> result = edgelist.groupby( edgeitem => edgeitem.source)
// keep only the groups with enough elements:
.where(group => group.skip(linkcount).any())
// ungroup, so we get a neat sequence
.selectmany(group => group);
Source: stackoverflow.com
Related Query
- How do you remove trailing objects from a list with linq?
- Lambda or LinQ expression to remove certain objects from List
- Remove objects with duplicate properties from List
- Best way to remove elements from list field of list objects
- How to remove (via linq) duplicates from a List of objects
- Remove objects, and child objects from a list in C# where they match an object property in another list
- GroupBy to remove duplicates from IEnumerable list of objects
- LINQ to remove objects from a list of objects based on another list of objects
- Remove specific items from list of objects
- how to remove objects from list by multiple variables using linq
- Remove objects from list
- C# LINQ Remove multiple objects from a list in single execution
- Remove duplicate objects with lowest Num property from list
- How do I remove objects with a combination of duplicate of two properties from List with linq?
- Remove duplicate objects from a list using LINQ in c#
- Remove duplicates from the list with lists as objects
- Remove from list a range based on an objects properties
- LINQ query to return distinct field values from list of objects
- Remove item from list based on condition
- how to remove empty strings from list, then remove duplicate values from a list
- How to Quickly Remove Items From a List
- Remove items of list from another lists with criteria
- LINQ select one field from list of DTO objects to array
- LINQ: From a list of type T, retrieve only objects of a certain subclass S
- Remove instances from a list by using LINQ or Lambda?
- Linq select object from list depending on objects attribute
- Remove items from list that intersect on property using Linq
- How to remove non-duplicates from a list in C#
- Remove item from list using linq
- Removing a list of objects from another list
More Query from same tag
- Linq query with OrderBy word count
- Create Linq Expression<Func<TModel, TDataType>> for the given property name
- Linq List Any can't handle Value command of generic List<List<T>>
- ordering of OrderBy, Where, Select in the Linq query
- Adding the Values of a Column which is in a DataTable in Memory
- compare two files based on datetime upto minute?
- LINQ SUM, AVERAGE
- Entity Framework gets progressively slow with extra join added even though SQL generated is fast
- Lambda function in LINQ select clause
- C# - Convert Implict Type to ObservableCollection
- LINQ group by sequence and count with sorting
- Convert Generic Method Parameter to Specific Type
- Linq "group by" values in a Dictionary property with a list of keys
- Replacing an object in list with a list in C#
- Does LINQ Enumerable query return copy or reference?
- enum bitwise/flags Instance enumeration/iteration/foreach
- Building Expression Trees
- c# group by multiple columns then select all fields where count > 1
- Why does my query fail to load related data in EF?
- Query MongoDb from C# - using Linq .Any() with predicate
- Repeatable logic for variety of objects
- Using Array and IEnumerable in an Extension Method
- Join With List Collection
- linq to sql query optimization suggestions needed
- MySql.Data.MySqlClient.MySqlException Timeout Expired c#
- EF Core can't translate an expression to compare two collections which EF 6 could
- Linq to SQL Slow Query
- Compare lists to retrieve object properties that don't match
- Reference Key Error in Transaction Scope Using Entity Framework
- LINQ to intersect elements of complex List<T> into new List<T>