Skip to content

Commit 5ac213c

Browse files
committed
delete id method, delete next method
1 parent 0f5c81d commit 5ac213c

File tree

4 files changed

+6
-21
lines changed

4 files changed

+6
-21
lines changed

solver/src/main/kotlin/org/ucfs/descriptors/DescriptorsStorage.kt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.ucfs.descriptors
22

33
import org.ucfs.parser.ParsingException
4+
import java.util.LinkedList
45

56
/**
67
* Collection of default descriptors
@@ -12,19 +13,10 @@ open class DescriptorsStorage<VertexType> {
1213
*/
1314
private val handledDescriptors = HashSet<Descriptor<VertexType>>()
1415

15-
private val descriptorsToHandle = ArrayDeque<Descriptor<VertexType>>()
16+
private val descriptorsToHandle = LinkedList<Descriptor<VertexType>>()
1617

1718
private fun isEmpty() = descriptorsToHandle.isEmpty()
1819

19-
/**
20-
* @return next default descriptor to handle
21-
*/
22-
open fun next(): Descriptor<VertexType> {
23-
if (isEmpty()) {
24-
throw ParsingException("Descriptor storage is empty")
25-
}
26-
return descriptorsToHandle.removeLast()
27-
}
2820

2921
fun addToHandled(descriptor: Descriptor<VertexType>) {
3022
handledDescriptors.add(descriptor)
@@ -42,7 +34,7 @@ open class DescriptorsStorage<VertexType> {
4234
*/
4335
fun nextToHandle(): Descriptor<VertexType>? {
4436
if (!isEmpty()) {
45-
return next()
37+
return descriptorsToHandle.removeLast()
4638
}
4739
return null
4840
}

solver/src/main/kotlin/org/ucfs/parser/IGll.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ interface IGll<InputNodeType, LabelType : ILabel> {
5454

5555
val gssNode = ctx.gss.getOrCreateNode(startVertex, ctx.fictiveStartState)
5656
val startDescriptor = Descriptor(
57-
startVertex, gssNode, ctx.fictiveStartState, getEmptyRange(ctx.sppfStorage.getId())
57+
startVertex, gssNode, ctx.fictiveStartState, getEmptyRange()
5858
)
5959
ctx.descriptors.add(startDescriptor)
6060
}
@@ -69,7 +69,7 @@ interface IGll<InputNodeType, LabelType : ILabel> {
6969
)
7070

7171
var newDescriptor = Descriptor(
72-
descriptor.inputPosition, newGssNode, rsmStartState, getEmptyRange(ctx.sppfStorage.getId())
72+
descriptor.inputPosition, newGssNode, rsmStartState, getEmptyRange()
7373
)
7474
ctx.descriptors.add(newDescriptor)
7575

solver/src/main/kotlin/org/ucfs/sppf/SppfStorage.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ open class SppfStorage<InputEdgeType> {
1414
*/
1515
private val createdSppfNodes: HashMap<RangeSppfNode<InputEdgeType>, RangeSppfNode<InputEdgeType>> = HashMap()
1616

17-
private var lastRangeId: Int = 0;
18-
19-
public fun getId(): Int{
20-
return lastRangeId++
21-
}
22-
2317
private fun addNode(node: RangeSppfNode<InputEdgeType>): RangeSppfNode<InputEdgeType> {
2418
return createdSppfNodes.getOrPut(node, { node })
2519
}

solver/src/main/kotlin/org/ucfs/sppf/node/RangeSppfNode.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import org.ucfs.rsm.symbol.ITerminal
1717
* May be used as extended packed sppfNode.
1818
* @param VertexType - type of vertex in input graph
1919
*/
20-
var lastId = 0
2120

2221
data class RangeSppfNode<VertexType>(
2322
val inputRange: InputRange<VertexType>?,
@@ -27,7 +26,7 @@ data class RangeSppfNode<VertexType>(
2726
val children = ArrayList<RangeSppfNode<VertexType>>()
2827
}
2928

30-
fun <VertexType> getEmptyRange(id: Int, isStart: Boolean = false): RangeSppfNode<VertexType> {
29+
fun <VertexType> getEmptyRange( isStart: Boolean = false): RangeSppfNode<VertexType> {
3130
val type = EmptyType()
3231
if(isStart) {
3332
type.isStart = isStart

0 commit comments

Comments
 (0)