Changeset 8262 for trunk/gli/src/org/greenstone/gatherer/util
- Timestamp:
- 2004-10-08T16:54:49+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/util/ArrayTools.java
r7985 r8262 13 13 import java.util.*; 14 14 import javax.swing.filechooser.*; 15 import org.greenstone.gatherer.file.FileNode;16 15 import org.w3c.dom.*; 17 16 … … 122 121 } 123 122 124 /** This method efficiently appends a new FileNode onto the end of a FileNode array.125 * @param a The initial <strong>FileNode[]</strong>.126 * @param b The new <strong>FileNode</strong>.127 * @return An <strong>FileNode[]</strong> containing a followed by b.128 */129 static public FileNode[] add(FileNode a[], FileNode b) {130 FileNode[] c = null;131 if(a != null && b != null) {132 c = new FileNode[a.length + 1];133 System.arraycopy(a, 0, c, 0, a.length);134 c[c.length - 1] = b;135 }136 else if(a == null && b != null) {137 c = new FileNode[1];138 c[0] = b;139 }140 else if(a != null && b == null) {141 c = a;142 }143 return c;144 }145 /** This method efficently appends one FileNode array onto the end of another FileNode array.146 * @param a The initial <strong>FileNode[]</strong>.147 * @param b The <strong>FileNode[]</strong> to append.148 * @return An <strong>FileNode[]</strong> containing a followed by b.149 */150 static final public FileNode[] add(FileNode a[], FileNode b[]) {151 FileNode[] c = null;152 if(a != null && b != null) {153 c = new FileNode[a.length + b.length];154 System.arraycopy(a, 0, c, 0, a.length);155 System.arraycopy(b, 0, c, a.length, b.length);156 }157 else if(a == null && b != null) {158 c = b;159 }160 else if(a != null && b == null) {161 c = a;162 }163 return c;164 }165 /** Determine if a certain FileNode is present in an array of FileNodes.166 * @param array The <strong>FileNode[]</strong>.167 * @param a The <strong>FileNode</strong> we are searching for.168 * @return <i>true</i> if the FileNode is in the array, <i>false</i> otherwise.169 */170 static final public boolean contains(FileNode array[], FileNode a) {171 for(int i = 0; i < array.length; i++) {172 if(array[i].equals(a)) {173 return true;174 }175 }176 return false;177 }178 123 179 124 /** This method efficiently appends a new node onto the end of a node array.
Note:
See TracChangeset
for help on using the changeset viewer.