Click here to Skip to main content
15,918,267 members
Home / Discussions / C#
   

C#

 
AnswerRe: Clearing an array of images Pin
Luc Pattyn29-Apr-10 1:07
sitebuilderLuc Pattyn29-Apr-10 1:07 
AnswerRe: Clearing an array of images Pin
AspDotNetDev29-Apr-10 11:54
protectorAspDotNetDev29-Apr-10 11:54 
QuestionEvery possible group of items in an array/set/... [SOLVED] Pin
Bart Van Eyndhoven28-Apr-10 21:59
Bart Van Eyndhoven28-Apr-10 21:59 
GeneralRe: Every possible group of items in an array/set/... Pin
harold aptroot28-Apr-10 22:09
harold aptroot28-Apr-10 22:09 
GeneralRe: Every possible group of items in an array/set/... Pin
Bart Van Eyndhoven28-Apr-10 22:59
Bart Van Eyndhoven28-Apr-10 22:59 
GeneralRe: Every possible group of items in an array/set/... Pin
Alan Balkany29-Apr-10 4:00
Alan Balkany29-Apr-10 4:00 
AnswerRe: Every possible group of items in an array/set/... Pin
PIEBALDconsult29-Apr-10 3:45
mvePIEBALDconsult29-Apr-10 3:45 
GeneralRe: Every possible group of items in an array/set/... Pin
Bart Van Eyndhoven29-Apr-10 22:21
Bart Van Eyndhoven29-Apr-10 22:21 
I've continued looking while I was waiting for answers and I found a quite simple way to do this. For my program, I had to build in a treshold calculation for performance purposes, but that's already done. Just the loops:

class ComboSearcher {
  private string[] _arCombos;
  private int[] _arIndeces;
  private string[] _arSourceArray;

  public ComboSearcher(string[] SourceArray) {
    _arSourceArray = SourceArray
  }

  private void AddItemInt(ref int[] ArrayToUpdate, int ItemToAdd) {
    int[] tmpArray;

    tmpArray = new string[ArrayToUpdate.length];

    for(int i=0; i<ArrayToUpdate.length; i++) {
      tmpArray[i] = ArrayToUpdate[i];
    }

    ArrayTuUpdate = tmpArray;
  }

  private void CutArrayInt(ref int[] ArrayToCut, int NewLength) {
    int[] tmpArray;

    tmpArray = new int[NewLength];

    for(int i=0; i<NewLengh; i++) {
      tmpArray[i] = ArrayToCut[i];
    }

    ArrayToCut = tmpArray;
  }

  private void SubCheck(int IndexNumber) {
    int i, j, minCount;

    //initialize _arCombos if it's not yet initialized
    _arCombos = new string[0]

    AddItemInt(_arIndeces, 0);

    if(_arIndeces.lengh > 1) {
      minCount = _arIndeces[_arIndeces.length - 2);
    }
    else {
      minCount = 0;
    }

    for(i=minCount; i<_arSource.length; i++) {
      _arIndeces[IndexNumber] = i;

      //put preparations to assemble combination here

      for(j=0; j<=IndexNumber; j++) {
        //add routine to assemble combination and perform checks here
      }

      if(_arIndeces.length<_arSourceArray.length) { //also add condition to check if the max number of items is reached when applicable
        CutArrayInt(_arIndeces, IndexNumber + 1);
      }
    }
  }

  public string[] Combinations() {
    //calculate max number of items when applicable

    _arCombos = null; //clear combination list

    SubCheck(0);

    return _arCombos
  }
}


Usage:

ComboSearcher cboSearch;

cboSearch=new ComboSearcher(source);
target=ComboSearcher.Combinations();

GeneralRe: Every possible group of items in an array/set/... Pin
harold aptroot29-Apr-10 6:01
harold aptroot29-Apr-10 6:01 
AnswerRe: Every possible group of items in an array/set/... Pin
Kythen29-Apr-10 6:44
Kythen29-Apr-10 6:44 
QuestionExcel Interop Pin
nuonxxx28-Apr-10 21:27
nuonxxx28-Apr-10 21:27 
Questiondelegates and events in c# Pin
jitendra sandu28-Apr-10 21:09
jitendra sandu28-Apr-10 21:09 
AnswerRe: delegates and events in c# Pin
Rajesh Anuhya28-Apr-10 21:15
professionalRajesh Anuhya28-Apr-10 21:15 
AnswerRe: delegates and events in c# Pin
nagendrathecoder28-Apr-10 21:18
nagendrathecoder28-Apr-10 21:18 
AnswerRe: delegates and events in c# Pin
Md. Marufuzzaman28-Apr-10 21:27
professionalMd. Marufuzzaman28-Apr-10 21:27 
Questionwhere is the site that i can download msdn for visual 2005? Pin
buffering8328-Apr-10 19:39
buffering8328-Apr-10 19:39 
AnswerRepost Pin
DaveyM6928-Apr-10 20:30
professionalDaveyM6928-Apr-10 20:30 
AnswerRe: where is the site that i can download msdn for visual 2005? Pin
Rajesh Anuhya28-Apr-10 21:12
professionalRajesh Anuhya28-Apr-10 21:12 
QuestionHow to Remove Sharing Permission of a Folder through c# Pin
himuskanhere28-Apr-10 18:37
himuskanhere28-Apr-10 18:37 
AnswerRe: How to Remove Sharing Permission of a Folder through c# Pin
Md. Marufuzzaman28-Apr-10 21:37
professionalMd. Marufuzzaman28-Apr-10 21:37 
QuestionPass ctrl + c to a process (console application) from another app/service Pin
Spunky Coder28-Apr-10 15:21
Spunky Coder28-Apr-10 15:21 
AnswerRe: Pass ctrl + c to a process (console application) from another app/service Pin
PIEBALDconsult28-Apr-10 16:11
mvePIEBALDconsult28-Apr-10 16:11 
AnswerRe: Pass ctrl + c to a process (console application) from another app/service Pin
#realJSOP29-Apr-10 1:49
professional#realJSOP29-Apr-10 1:49 
QuestionCombinations Pin
James Towers28-Apr-10 10:59
James Towers28-Apr-10 10:59 
AnswerRe: Combinations Pin
Luc Pattyn28-Apr-10 11:54
sitebuilderLuc Pattyn28-Apr-10 11:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.