LightVoting
 All Classes Namespaces Files Functions Variables Pages
org.lightvoting.simulation.combinations.CCombination Class Reference

Created by sophie on 08.02.17. More...

Inherits Object.

+ Collaboration diagram for org.lightvoting.simulation.combinations.CCombination:

Public Member Functions

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 More...
 
List< int[]> getResultList ()
 

Private Attributes

List< int[]> m_resultList = new ArrayList<>()
 

Detailed Description

Member Function Documentation

void org.lightvoting.simulation.combinations.CCombination.combinations ( final int[]  p_arr,
final int  p_len,
final int  p_startPosition,
final int[]  p_result 
)
Parameters
p_arrint[] array
p_lennumber of ones
p_startPositionstart position for searching combinations
p_resultposition array

Definition at line 54 of file CCombination.java.

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  }
List<int[]> org.lightvoting.simulation.combinations.CCombination.getResultList ( )

Definition at line 41 of file CCombination.java.

References org.lightvoting.simulation.combinations.CCombination.m_resultList.

42  {
43  return new ArrayList<>( m_resultList );
44  }

Member Data Documentation

List<int[]> org.lightvoting.simulation.combinations.CCombination.m_resultList = new ArrayList<>()
private