MCPcopy Create free account
hub / github.com/careercup/ctci / insertLine

Method insertLine

java/Chapter 7/Question7_6/Question.java:36–46  ·  view source on GitHub ↗
(HashMap<Double, ArrayList<Line>> linesBySlope, Line line)

Source from the content-addressed store, hash-verified

34
35 /* insert line into hashmap */
36 public static void insertLine(HashMap<Double, ArrayList<Line>> linesBySlope, Line line) {
37 ArrayList<Line> lines = null;
38 double key = Line.floorToNearestEpsilon(line.slope);
39 if (!linesBySlope.containsKey(key)) {
40 lines = new ArrayList<Line>();
41 linesBySlope.put(key, lines);
42 } else {
43 lines = linesBySlope.get(key);
44 }
45 lines.add(line);
46 }
47
48
49 public static Line findBestLine(GraphPoint[] points) {

Callers 1

findBestLineMethod · 0.95

Calls 4

floorToNearestEpsilonMethod · 0.95
putMethod · 0.80
getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected