Package com.nailgun.study.algo

Source Code of com.nailgun.study.algo.Assignment6_1

package com.nailgun.study.algo;

import java.util.ArrayList;
import java.util.List;

import com.nailgun.study.algo.counter.TwoSumCounter;
import com.nailgun.study.algo.counter.TwoSumCounterHashSetImpl;
import com.nailgun.study.algo.extractor.IntListExtractor;
import com.nailgun.study.algo.extractor.IntListExtractorFileImpl;

public class Assignment6_1 {
 
  private static final List<Integer> RANGE = new ArrayList<Integer>(1501);
 
  static{
    for (Integer i = 2500; i <= 4000; i++){
      RANGE.add(i);
    }
  }
 
  public static void main(String[] args) {
    IntListExtractor extractor = new IntListExtractorFileImpl();
    List<Integer> ints = extractor.extract();
    TwoSumCounter counter = new TwoSumCounterHashSetImpl(ints);
    int result = 0;
    for (Integer t: RANGE){
      if (counter.count(t) > 0) {
        result++;
        System.out.println("Matches for: " + t);
      }
    }
    System.out.println("Result: " + result);
  }

}
TOP

Related Classes of com.nailgun.study.algo.Assignment6_1

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.