@Override
    public LinkSetNode getNextInOrder(){
        try
        {
        if(memory == null)
        {
            int r = in.read(b);
            if(r != b.length)
            {
                in.close();
                return null;
            }
        }
        else
        {
            if(memory.position() == memory.capacity())
            {
                return null;
            }
            memory.get(b);
        }
        switch(type)
        {
            case 1:
                return new LinkSetNode(b);
            case 3:
                return new TimedLinkSetNode(b);
            default:
                System.out.println("Error. Unknown LinkSetNode type in preamble");
                in.close();
                System.exit(22);
                break;
        }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        return null;
    }