Package it.unimi.dsi.webgraph.labelling
Class FixedWidthIntLabel
java.lang.Object
it.unimi.dsi.webgraph.labelling.AbstractLabel
it.unimi.dsi.webgraph.labelling.AbstractIntLabel
it.unimi.dsi.webgraph.labelling.FixedWidthIntLabel
An integer represented in fixed width. The provided width must
be smaller than 32.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intThe bit width used to represent the value of this label.Fields inherited from class it.unimi.dsi.webgraph.labelling.AbstractIntLabel
key, valueFields inherited from interface it.unimi.dsi.webgraph.labelling.Label
EMPTY_LABEL_ARRAY -
Constructor Summary
ConstructorsConstructorDescriptionFixedWidthIntLabel(String... arg) Creates a new fixed-width integer label using the given key and width with value 0.FixedWidthIntLabel(String key, int width) Creates a new fixed-width int label of value 0.FixedWidthIntLabel(String key, int width, int value) Creates a new fixed-width int label. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Returns a copy of this label.intReturns the width of this label (as provided at construction time).intfromBitStream(it.unimi.dsi.io.InputBitStream inputBitStream, int sourceUnused) Fills this label with data from the given input bit stream, knowing the source node of the arc.inttoBitStream(it.unimi.dsi.io.OutputBitStream outputBitStream, int sourceUnused) Writes out this label to the given input bit stream, in self-delimiting form, knowing the source node of the arc.toSpec()Returns a string representing the specification of this label.toString()Methods inherited from class it.unimi.dsi.webgraph.labelling.AbstractIntLabel
attributeKeys, attributeTypes, equals, get, get, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getLong, getLong, hashCode, wellKnownAttributeKeyMethods inherited from class it.unimi.dsi.webgraph.labelling.AbstractLabel
getBoolean, getBoolean, getByte, getByte, getChar, getChar, getShort, getShortMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface it.unimi.dsi.webgraph.labelling.Label
getBoolean, getBoolean, getByte, getByte, getChar, getChar, getShort, getShort
-
Field Details
-
width
protected final int widthThe bit width used to represent the value of this label.
-
-
Constructor Details
-
FixedWidthIntLabel
Creates a new fixed-width int label.- Parameters:
key- the (only) key of this label.width- the label width (in bits).value- the value of this label.
-
FixedWidthIntLabel
Creates a new fixed-width int label of value 0.- Parameters:
key- the (only) key of this label.width- the label width (in bits).
-
FixedWidthIntLabel
Creates a new fixed-width integer label using the given key and width with value 0.- Parameters:
arg- two strings containing the key and the width of this label.
-
-
Method Details
-
copy
Description copied from interface:LabelReturns a copy of this label.- Returns:
- a new label that copies this one.
-
fromBitStream
public int fromBitStream(it.unimi.dsi.io.InputBitStream inputBitStream, int sourceUnused) throws IOException Description copied from interface:LabelFills this label with data from the given input bit stream, knowing the source node of the arc. IfLabel.fixedWidth()is not negative, the value returned must coincide withLabel.fixedWidth(). This method is optional.- Parameters:
inputBitStream- an input bit stream offering a label.sourceUnused- the source node.- Returns:
- the number of bits read to fill this label.
- Throws:
IOException
-
toBitStream
public int toBitStream(it.unimi.dsi.io.OutputBitStream outputBitStream, int sourceUnused) throws IOException Description copied from interface:LabelWrites out this label to the given input bit stream, in self-delimiting form, knowing the source node of the arc. IfLabel.fixedWidth()is not negative, the value returned must coincide withLabel.fixedWidth(). This method is optional.- Parameters:
outputBitStream- an output bit stream where the label will be written.sourceUnused- the source node.- Returns:
- the number of bits written.
- Throws:
IOException
-
fixedWidth
public int fixedWidth()Returns the width of this label (as provided at construction time).- Returns:
- the width of this label.
-
toString
- Overrides:
toStringin classAbstractIntLabel
-
toSpec
Description copied from interface:LabelReturns a string representing the specification of this label.Each label class can be instantiated in several ways (e.g.,
FixedWidthIntLabelrequires a name for the well-known attribute and a number of bits). This method must return a representation that can be used byObjectParserto instantiate the class, and consequently there must exist a matching constructor whose arguments are strings.There is an equation that must be always satisfied:
ObjectParser.fromSpec(x.toSpec()).toSpec().equals(x.toSpec())
- Returns:
- a string representing the specification of this label.
- See Also:
-