Pagano
Pagano
CC#
Created by Pagano on 7/12/2024 in #help
Custom Made Collection
As the way to compare two Lists and Players will always be this way
103 replies
CC#
Created by Pagano on 7/12/2024 in #help
Custom Made Collection
I ended up doing it this way but I didn't have time to test it yet:
public IEnumerable<Player> Intersect(IEnumerable<Player> targets)
{
var intersectedPlayers = new List<Player>();
foreach (var player in this)
{
foreach (var otherPlayer in targets)
{
if (0.7 * player.SkillRating.SkillRating <= otherPlayer.SkillRating.SkillRating * 1.3
&& 07 * otherPlayer.SkillRating.SkillRating <= player.SkillRating.SkillRating * 1.3)
{
intersectedPlayers.Add(otherPlayer);
}
}
}

return intersectedPlayers;
}
public IEnumerable<Player> Intersect(IEnumerable<Player> targets)
{
var intersectedPlayers = new List<Player>();
foreach (var player in this)
{
foreach (var otherPlayer in targets)
{
if (0.7 * player.SkillRating.SkillRating <= otherPlayer.SkillRating.SkillRating * 1.3
&& 07 * otherPlayer.SkillRating.SkillRating <= player.SkillRating.SkillRating * 1.3)
{
intersectedPlayers.Add(otherPlayer);
}
}
}

return intersectedPlayers;
}
103 replies
CC#
Created by Pagano on 7/12/2024 in #help
Custom Made Collection
But I would need help with this
103 replies
CC#
Created by Pagano on 7/12/2024 in #help
Custom Made Collection
Ok, I ended up with this so far and it seems to work:
public required LeagueRoles Role { get; init; }

public new void Add(Player player)
{
if (!this.Contains(player))
base.Add(player);
}

public Player Pop()
{
Player player = this.ElementAt(0);
this.Remove(player);
return player;
}
}
public required LeagueRoles Role { get; init; }

public new void Add(Player player)
{
if (!this.Contains(player))
base.Add(player);
}

public Player Pop()
{
Player player = this.ElementAt(0);
this.Remove(player);
return player;
}
}
103 replies
CC#
Created by Pagano on 7/12/2024 in #help
Custom Made Collection
A normal List<T> should work then? 🤔
103 replies
CC#
Created by Pagano on 7/12/2024 in #help
Custom Made Collection
Nevermind
103 replies
CC#
Created by Pagano on 7/12/2024 in #help
Custom Made Collection
Does a normal HashSet<T> guarantees order of insertion?
103 replies
CC#
Created by Pagano on 7/12/2024 in #help
Custom Made Collection
Ok I see it now
103 replies
CC#
Created by Pagano on 7/12/2024 in #help
Custom Made Collection
Ok
103 replies
CC#
Created by Pagano on 7/12/2024 in #help
Custom Made Collection
I am using SortedSet<Player> I don't have an index so wouldn't it ensure that?
103 replies
CC#
Created by Pagano on 7/12/2024 in #help
Custom Made Collection
So it doesn't maintain order of insertion?
103 replies
CC#
Created by Pagano on 7/12/2024 in #help
Custom Made Collection
Than using a SortedList as the only method I need that relates it to a Queue is the Dequeue as SortedList Add() already inserts in the last index right?
103 replies
CC#
Created by Pagano on 7/12/2024 in #help
Custom Made Collection
I am confused
103 replies
CC#
Created by Pagano on 7/12/2024 in #help
Custom Made Collection
What is the second param?
103 replies
CC#
Created by Pagano on 7/12/2024 in #help
Custom Made Collection
This is the method:
public IEnumerable<Player> Intersect(IEnumerable<Player> targets, secondParam)
{

}
public IEnumerable<Player> Intersect(IEnumerable<Player> targets, secondParam)
{

}
103 replies
CC#
Created by Pagano on 7/12/2024 in #help
Custom Made Collection
May I ask how to implement an Intersect method for my class that has a target parameter that is another IEnumerable of the same type and a delegate that is what field I am comparing?
103 replies
CC#
Created by Pagano on 7/12/2024 in #help
Custom Made Collection
Isn't that less efficient?
103 replies
CC#
Created by Pagano on 7/12/2024 in #help
Custom Made Collection
Always in the last
103 replies
CC#
Created by Pagano on 7/12/2024 in #help
Custom Made Collection
I need to maintain the order and I don't need to insert in the middle or first position
103 replies
CC#
Created by Pagano on 7/12/2024 in #help
Custom Made Collection
I actually ended up with this by now:
public class EvoHubQueue : SortedSet<Player>
{
public required LeagueRoles Role { get; init; }

public Player Pop()
{
Player player = this.ElementAt(0);
this.Remove(player);
return player;
}
}
public class EvoHubQueue : SortedSet<Player>
{
public required LeagueRoles Role { get; init; }

public Player Pop()
{
Player player = this.ElementAt(0);
this.Remove(player);
return player;
}
}
103 replies