-
Notifications
You must be signed in to change notification settings - Fork 0
/
PopData.java
47 lines (40 loc) · 1.24 KB
/
PopData.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* xxx Copyright (c) 2016, Carnegie Mellon University. All Rights Reserved.
* Version 3.1.2.
*/
import java.io.*;
import java.util.*;
/**
* PopData is a simple utility class for returning two items (a tuple
* of length two) from a method. The tuple represents data that was
* popped from a string, and the remaining part of the string. This
* class would not be necessary if Java strings were not immutable or
* if Java methods could return more than a single object.
*/
public class PopData<PopType,RemainingType> {
private final PopType popped;
private final RemainingType remaining;
/**
* Constructor.
* @param popped The data that was popped from the string.
* @param remaining The data that remains in the string after the pop.
*/
public PopData(PopType popped, RemainingType remaining) {
this.popped = popped;
this.remaining = remaining;
}
/**
* Get the data that was popped from the string.
* @return PopType The data that was popped.
*/
public PopType getPopped() {
return this.popped;
}
/**
* Get the data that remains in the string after the pop.
* @return RemainingType The data that remains.
*/
public RemainingType getRemaining() {
return this.remaining;
}
}