summaryrefslogtreecommitdiff
path: root/src/main/java/net/transit/packet/ArrayPacket.java
blob: 09ef5f16c028103594fe3a19c6fc1daa8e5bab30 (plain)
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
package net.transit.packet;

import java.util.ArrayList;

public class ArrayPacket<D> implements IPacket<D>
{
    private ArrayList<D> arrayData;

    public ArrayPacket(D startValue)
    {
        arrayData = new ArrayList<D>(0);
        arrayData.add(startValue);
    }

    public D getData()
    {
        if(arrayData.size() > 0) return arrayData.get(0);
        return null;
    }

    public void addData(D data)
    {
        arrayData.add(data);
    }

    public D popAndShift()
    {
        D temp = null;
        
        if(arrayData.size() > 0)
        {
            temp = arrayData.remove(0);
        }

        return temp;
    }
}