Hello guys I've got question about Java 8 lambda expression. For example I want to delete following id from class.
UserEntity userEntity = userEntityOptional.get();
for(Long permission_id : deletePermissionDto.getPermissionId())
{
for(PrivilegeEntity p : userEntity.getPrivilegeEntities())
{
if(p.getId().equals(permission_id)){
userEntity.getPrivilegeEntities().remove(p);
break;
}
}
}
Similar to This code might be implemented in java 8 using a lambda expression.
userEntity.getPrivilegeEntities().removeIf(i -> deletePermissionDto.getPermissionId().stream().anyMatch(i.getId()::equals));
What I curious to know asymptotic of java 8 implementation of the same with the first block of code. And how do you think what the best way of implementation of this code.