package com.github.jhanne82.documenttree;


import com.github.jhanne82.documenttree.component.Document;
import com.github.jhanne82.documenttree.component.DocumentNode;
import com.github.jhanne82.documenttree.component.DocumentTree;
import com.github.jhanne82.documenttree.numbergenerator.Distribution;
import com.github.jhanne82.documenttree.numbergenerator.RandomNumberGenerator;


public class Simulation {


    private static final int MAX_COUNT_OF_CREATED_DOCUMENTS = 1000;
    private static final int MAX_COUNT_OF_TERMS_USED_TO_DEFINE_DOCUMENT = 1000;
    private static final int MAX_COUNT_OF_TERMS_WITH_QUANTIFIER = 3;

    private Document<Integer>[] referenceTree;
    DocumentTree<Integer> globalKnowledge = new DocumentTree();
    DocumentTree<Integer> localKnowledge  = new DocumentTree();



    public Simulation( boolean useCluster,
                       Distribution distributionDocuments,
                       Distribution distributionSearch ) {

        createDocumentTree( distributionDocuments );
    }


    private void createDocumentTree( Distribution distribution ) {
        referenceTree = createDocuments( MAX_COUNT_OF_CREATED_DOCUMENTS );

        globalKnowledge.level_order_insert( globalKnowledge.rootNode, referenceTree, 0, MAX_COUNT_OF_CREATED_DOCUMENTS );
        localKnowledge.level_order_insert(  localKnowledge.rootNode, referenceTree, 0, MAX_COUNT_OF_CREATED_DOCUMENTS );
    }



    private Document<Integer>[] createDocuments( int size ) {

        Document<Integer>[] documents = new Document[ size ];

        for( int i = 0; i < size; i++ ) {
            documents[i] = createDocument( Distribution.EQUALLY );
        }

        return documents;
    }



    private Document<Integer> createDocument( Distribution distribution ) {

        Integer[] termVector = new Integer[MAX_COUNT_OF_TERMS_USED_TO_DEFINE_DOCUMENT];
        for( int i = 0; i < MAX_COUNT_OF_TERMS_WITH_QUANTIFIER ; ) {
            int index = (new RandomNumberGenerator( distribution,
                                                    MAX_COUNT_OF_TERMS_USED_TO_DEFINE_DOCUMENT ) ).getInt();
            if ( termVector[ index ] == null ) {
                termVector[index] = 1;
                i++;
            }
        }
        return new Document<>( termVector );
    }



}

@@ -101,72 +101,8 @@
 nt;%0A
-import com.github.jhanne82.documenttree.component.DocumentNode;%0A
 impo
@@ -161,16 +161,16 @@
 ntTree;%0A
+
 import c
@@ -605,24 +605,32 @@
 ceTree;%0A    
+private 
 DocumentTree
@@ -673,24 +673,26 @@
 mentTree
+%3C%3E
 ();%0A    
 Document
@@ -679,24 +679,32 @@
 ee%3C%3E();%0A    
+private 
 DocumentTree
@@ -747,16 +747,18 @@
 mentTree
+%3C%3E
 ();%0A%0A%0A%0A 
@@ -1113,24 +1113,38 @@
 ED_DOCUMENTS
+, distribution
  );%0A%0A       
@@ -1445,16 +1445,43 @@
 int size
+, Distribution distribution
  ) %7B%0A%0A  
@@ -1618,33 +1618,33 @@
 createDocument( 
-D
+d
 istribution.EQUA
@@ -1642,16 +1642,8 @@
 tion
-.EQUALLY
  );%0A

remove some warnings