Program: 179652
Project: 179652
Buggy source:
/** 
 * Gets the next available item in this list. The item provided is determined by its weight.  This list will provide elements in a weighted round robin fashion.  Distributing the elements of this list in weighted round robin fashion allows for efficiency in load balancing the distribution of elements in this list. <p>For example, the following code illustrates how this list effectively load balances the distribution of elements contained in this list.  {@code LoadBalanceList<String> list = new WeightedRoundRobinList<String>(); list.add("low", 1); list.add("mid", 2); list.add("high", 3);}for (String element : list)  System.out.println(item + " "); }} will produce the following output: <em>low mid high mid high high </em> <p>As you can see the code above yields each element the number of times defined by its weight for each complete iteration of this list. <p>Its important to note that each call to this lists   {@code iterator}method, resets the current position of this list. Calling   {@code get}several times, then calling the   {@code iterator} method, resets thislist to a state that is equal to this lists  {@code get} method neverbeing called.
 * @return
 */
public E get(){
  if (elements.size() == 0)   return null;
  if (isDistributionComplete()) {
    resetDistributionCounts();
    position=0;
  }
  boolean found=false;
  while (!found) {
    if (position >= elements.size()) {
      position=0;
    }
    Element node=elements.get(position);
    if (node.getCount() < node.getWeight()) {
      node.incrementCount();
      found=true;
    }
 else {
      position++;
    }
  }
  Element<E> result=elements.get(position++);
  return result.getValue();
}

Fixed version (ground truth):
/** 
 * Gets the next available item in this list. The item provided is determined by its weight.  This list will provide elements in a weighted round robin fashion.  Distributing the elements of this list in weighted round robin fashion allows for efficiency in load balancing the distribution of elements in this list. <p>For example, the following code illustrates how this list effectively load balances the distribution of elements contained in this list. <pre>  {@code LoadBalanceList<String> list = new WeightedRoundRobinList<String>(); list.add("low", 1); list.add("mid", 2); list.add("high", 3);}for (String element : list)  System.out.println(item + " "); }} </pre> <p>will produce the following output: <em>low mid high mid high high </em> <p>As you can see the code above yields each element the number of times defined by its weight for each complete iteration of this list. <p>Its important to note that each call to this lists   {@code iterator}method, resets the current position of this list. Calling   {@code get}several times, then calling the   {@code iterator} method, resets thislist to a state that is equal to this lists  {@code get} method neverbeing called.
 * @return
 */
public E get(){
  if (elements.size() == 0)   return null;
  if (isDistributionComplete()) {
    resetDistributionCounts();
    position=0;
  }
  boolean found=false;
  while (!found) {
    if (position >= elements.size()) {
      position=0;
    }
    Element node=elements.get(position);
    if (node.getCount() < node.getWeight()) {
      node.incrementCount();
      found=true;
    }
 else {
      position++;
    }
  }
  Element<E> result=elements.get(position++);
  return result.getValue();
}