I have a map I want to loop through and remove all duplicate items. Is there a method that can be used like my pseudo code has?
public Map<String, User[]> allPeople {
Map<String, User[]> teams = new Map<String, User[]>();
....
return teams;
}
public plcontroller(){
for(User[] loopOverAllPeople : allPeople.values()){
system.debug('*current person: ' + loopOverAllPeople);
****pseudo code****
if(allPeople.get(loopOverAllPeople.Name()) > 1) {
loopOverAllPeople.Name.remove();
}
}
}
This is what the system debug looks like:
Administration=(User:{Name=Joe Smith, Title=CEO, Department=Administration, UserRoleId=1111, Leadership__c=true, Id=123}, User:{Name=Ally Scott, Title=Receptionist, Department=Administration, ManagerId=987xxxasf, UserRoleId=222, Leadership__c=false, Id=543543}, User:{Name=Billy Bob, Title=Receptionist, Department=Administration, ManagerId=0054354AS, UserRoleId=333, Leadership__c=false, Id=G}, User:{Name=Joe Smith, Title=CEO, Department=Administration, UserRoleId=1111, Leadership__c=true, Id=123}, User:{Name=Julia Emez, Title=Receptionist, Department=Administration, Extension=789, Phone=896-899-8745, ManagerId=7894651312, UserRoleId=444, Leadership__c=false, Id=675444566}),
Analytics=(User:{Name=Tommy Boy, Title=Director of Analytics, Department=Analytics, UserRoleId=77888, Leadership__c=true, Id=6543654}, User:{Name=Amy Smith, Title=Data Scientist, Department=Analytics, Extension=55, Phone=508-998-8855, ManagerId=45534654654, UserRoleId=22222, Leadership__c=false, Id=545345421}, User:{Name=Tommy Boy, Title=Director of Analytics, Department=Analytics, UserRoleId=77888, Leadership__c=true, Id=6543654}),
etc...
Map<string, Map<string, User>>where the inner string is the user name. – Daniel Ballinger 11 hours ago