Landis.Harvest.StandSpreading.AddUnharvestedNeighbors C# (CSharp) Method

AddUnharvestedNeighbors() public method

Adds a stand's unharvested neighbors and their rankings to a sorted list of stand rankings.
The stand rankings are in highest to lowest order. A neighbor is only added to the list if its rank is > 0 and it isn't already in the list.
public AddUnharvestedNeighbors ( Stand stand, List neighborRankings ) : void
stand Stand
neighborRankings List
return void
        public void AddUnharvestedNeighbors(Stand              stand,
                                            List<StandRanking> neighborRankings)
        {
            foreach (Stand neighbor in stand.Neighbors) {
                if (! neighbor.Harvested) {
                    bool inList = false;
                    foreach (StandRanking ranking in neighborRankings) {
                        if (ranking.Stand == neighbor) {
                            inList = true;
                            break;
                        }
                    }
                    if (inList)
                        continue;

                    StandRanking neighborRanking = GetRanking(neighbor);
                    if (neighborRanking.Rank <= 0)
                        continue;

                    int i;
                    for (i = 0; i < neighborRankings.Count; i++) {
                        if (neighborRankings[i].Rank < neighborRanking.Rank)
                            break;
                    }
                    neighborRankings.Insert(i, neighborRanking);
                }
            }
        }