LightVoting
 All Classes Namespaces Files Functions Variables Pages
CCombination.java
Go to the documentation of this file.
1 
24 package org.lightvoting.simulation.combinations;
25 
26 import java.util.ArrayList;
27 import java.util.Arrays;
28 import java.util.List;
29 
36 public class CCombination extends Object
37 {
38 
39  private List<int[]> m_resultList = new ArrayList<>();
40 
41  public List<int[]> getResultList()
42  {
43  return new ArrayList<>( m_resultList );
44  }
45 
54  public void combinations( final int[] p_arr, final int p_len, final int p_startPosition, final int[] p_result )
55  {
56  if ( p_len == 0 )
57  {
58  m_resultList.add( Arrays.copyOf( p_result, p_result.length ) );
59  return;
60  }
61 
62  for ( int i = p_startPosition; i <= p_arr.length - p_len; i++ )
63  {
64  p_result[p_result.length - p_len] = p_arr[i];
65  this.combinations( p_arr, p_len - 1, i + 1, p_result );
66  }
67  }
68 
69 }
void combinations(final int[] p_arr, final int p_len, final int p_startPosition, final int[] p_result)
compute possible positions of the ones in the committee