Example #1
0
    /// <summary>
    /// Remove an entry from the weight table
    /// </summary>
    /// <param name="ID">an integer ID, unique in this table</param>
    public void removeAt(int ID)
    {
        for (int ii = 0; ii < weightTable.Count; ii++)
        {
            WeightTableEntry entry = weightTable[ii];

            if (entry.uniqueID == ID)
            {
                weightSum -= entry.weight;
                weightTable.RemoveAt(ii);
                break;
            }
        }
    }
Example #2
0
    /// <summary>
    /// Set the weight for a given ID
    /// </summary>
    /// <param name="ID">an integer ID, unique in this table </param>
    /// <param name="newWeight"> the weight assigne to ID </param>
    public void setWeightForUniqueID(int ID, int newWeight)
    {
        for (int ii = 0; ii < weightTable.Count; ii++)
        {
            WeightTableEntry entry = weightTable[ii];

            if (entry.uniqueID == ID)
            {
                weightSum      += newWeight - entry.weight;
                weightTable[ii] = new WeightTableEntry {
                    uniqueID = ID, weight = newWeight
                };
                break;
            }
        }
    }