Returns the index of the first occurrence of the object, starting from the top of the stack. @return the index of the first occurrence of the object, assuming that the topmost object on the stack has a distance of one. @param o the object to be searched.
(Object o)
| 104 | * the object to be searched. |
| 105 | */ |
| 106 | public synchronized int search(Object o) { |
| 107 | final Object[] dumpArray = elementData; |
| 108 | final int size = elementCount; |
| 109 | if (o != null) { |
| 110 | for (int i = size - 1; i >= 0; i--) { |
| 111 | if (o.equals(dumpArray[i])) { |
| 112 | return size - i; |
| 113 | } |
| 114 | } |
| 115 | } else { |
| 116 | for (int i = size - 1; i >= 0; i--) { |
| 117 | if (dumpArray[i] == null) { |
| 118 | return size - i; |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | return -1; |
| 123 | } |
| 124 | } |