Class PatchNames

java.lang.Object
net.mtrop.doom.texture.PatchNames
All Implemented Interfaces:
Iterable<String>, BinaryObject, Sizable

public class PatchNames extends Object implements BinaryObject, Iterable<String>, Sizable
A list of names of available patch entries for texture composition. Texture patches use indices that reference this list.
Author:
Matthew Tropiano
  • Field Details

  • Constructor Details

    • PatchNames

      public PatchNames()
      Creates a new PatchNames with a default starting capacity.
  • Method Details

    • clear

      public void clear()
      Clears this list of patches.
    • add

      public int add(String name)
      Adds a patch entry.
      Parameters:
      name - the entry name.
      Returns:
      the index of the added entry, or an existing index if it was already in the list.
      Throws:
      IllegalArgumentException - if the provided name is not a valid entry name.
      See Also:
    • get

      public String get(int index)
      Gets the patch entry at a specific index.
      Parameters:
      index - the index to look up.
      Returns:
      the corresponding index or null if no corresponding entry.
    • indexOf

      public int indexOf(String name)
      Gets the index of a patch name in this lump by its name. Search is sequential.
      Parameters:
      name - the name of the patch.
      Returns:
      a valid index if found, or -1 if not.
    • remove

      public boolean remove(String name)
      Attempts to remove an entry by its name. Note that this will shift the indices of the other entries.
      Parameters:
      name - the name of the entry.
      Returns:
      true if removed, false if not.
    • removeIndex

      public String removeIndex(int index)
      Removes an entry at an index. Note that this will shift the indices of the other entries.
      Parameters:
      index - the index to use.
      Returns:
      the entry removed, or null if no entry at that index.
    • readBytes

      public void readBytes(InputStream in) throws IOException
      Description copied from interface: BinaryObject
      Reads from an InputStream and sets this object's fields. Only reads the amount of bytes that it takes to read a single instance of the object. Note that not every object may have a consistent length!
      Specified by:
      readBytes in interface BinaryObject
      Parameters:
      in - the InputStream to read from.
      Throws:
      IOException - if a read error occurs.
    • writeBytes

      public void writeBytes(OutputStream out) throws IOException
      Description copied from interface: BinaryObject
      Writes this object to an OutputStream.
      Specified by:
      writeBytes in interface BinaryObject
      Parameters:
      out - the OutputStream to write to.
      Throws:
      IOException - if a write error occurs.
    • iterator

      public AbstractVector.VectorIterator iterator()
      Specified by:
      iterator in interface Iterable<String>
    • size

      public int size()
      Specified by:
      size in interface Sizable
      Returns:
      the amount of individual objects that this object contains.
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: Sizable
      Returns if this object contains no objects. The general policy of this method is that this returns true if and only if Sizable.size() returns 0.
      Specified by:
      isEmpty in interface Sizable
      Returns:
      true if so, false otherwise.