-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: I7509a653ad429d329165e968358cf4d01bf86742
- Loading branch information
Showing
8 changed files
with
303 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...graph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/records/ArrayRecord.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright 2017 HugeGraph Authors | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with this | ||
* work for additional information regarding copyright ownership. The ASF | ||
* licenses this file to You under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.baidu.hugegraph.traversal.algorithm.records; | ||
|
||
import org.eclipse.collections.api.iterator.IntIterator; | ||
|
||
import com.baidu.hugegraph.util.collection.Int2IntsMap; | ||
|
||
public class ArrayRecord implements Record { | ||
|
||
private Int2IntsMap layer; | ||
|
||
public ArrayRecord() { | ||
this.layer = new Int2IntsMap(); | ||
} | ||
|
||
@Override | ||
public IntIterator keys() { | ||
return this.layer.keyIterator(); | ||
} | ||
|
||
@Override | ||
public boolean containsKey(int key) { | ||
return this.layer.containsKey(key); | ||
} | ||
|
||
@Override | ||
public IntIterator get(int key) { | ||
return new IntArrayIterator(this.layer.get(key)); | ||
} | ||
|
||
@Override | ||
public void addPath(int node, int parent) { | ||
this.layer.add(node, parent); | ||
} | ||
|
||
@Override | ||
public int size() { | ||
return this.layer.size(); | ||
} | ||
|
||
public class IntArrayIterator implements IntIterator { | ||
|
||
private int[] array; | ||
private int index; | ||
|
||
public IntArrayIterator(int[] array) { | ||
this.array = array; | ||
this.index = 0; | ||
} | ||
|
||
@Override | ||
public int next() { | ||
return this.array[index++]; | ||
} | ||
|
||
@Override | ||
public boolean hasNext() { | ||
return this.index < this.array.length; | ||
} | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...raph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/records/IntSetRecord.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2017 HugeGraph Authors | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with this | ||
* work for additional information regarding copyright ownership. The ASF | ||
* licenses this file to You under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.baidu.hugegraph.traversal.algorithm.records; | ||
|
||
import org.eclipse.collections.api.iterator.IntIterator; | ||
import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap; | ||
import org.eclipse.collections.impl.set.mutable.primitive.IntHashSet; | ||
|
||
public class IntSetRecord implements Record { | ||
|
||
private IntObjectHashMap<IntHashSet> layer; | ||
|
||
public IntSetRecord() { | ||
this.layer = new IntObjectHashMap<>(); | ||
} | ||
|
||
@Override | ||
public IntIterator keys() { | ||
return this.layer.keySet().intIterator(); | ||
} | ||
|
||
|
||
@Override | ||
public boolean containsKey(int key) { | ||
return this.layer.containsKey(key); | ||
} | ||
|
||
@Override public IntIterator get(int key) { | ||
return this.layer.get(key).intIterator(); | ||
} | ||
|
||
@Override | ||
public void addPath(int node, int parent) { | ||
if (this.layer.containsKey(node)) { | ||
this.layer.get(node).add(parent); | ||
} else { | ||
this.layer.put(node, IntHashSet.newSetWith(parent)); | ||
} | ||
} | ||
|
||
@Override | ||
public int size() { | ||
return this.layer.size(); | ||
} | ||
} |
214 changes: 0 additions & 214 deletions
214
...src/main/java/com/baidu/hugegraph/traversal/algorithm/records/MultiPathsBySetRecords.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.