Let's suppose I have this struct:
struct Agent {
uint idAgent;
address direction;
uint[] preferences;
}
Agent[] agents;
And there's a function:
/// @notice Registra a un nuevo agente a la subasta
/// @param _idAgent identificador del agente dentro de la subasta
/// @param _preferences preferencias del agente
function regAgent(uint[] _preferences) public{
Agent memory newAgent = Agent(numAgents, msg.sender, _preferences);
agents.push(newAgent);
numAgents++;
}
When an agent tries to register twice, how can I check it? I want to check that the agent is already registered but I don't want to go through the agent array. Is that possible?