src/java.xml/share/classes/com/sun/org/apache/xpath/internal/axes/IteratorPool.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * reserved comment block |
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT REMOVE OR ALTER! |
3 * @LastModified: Oct 2017 |
4 */ |
4 */ |
5 /* |
5 /* |
6 * Licensed to the Apache Software Foundation (ASF) under one or more |
6 * Licensed to the Apache Software Foundation (ASF) under one or more |
7 * contributor license agreements. See the NOTICE file distributed with |
7 * contributor license agreements. See the NOTICE file distributed with |
8 * this work for additional information regarding copyright ownership. |
8 * this work for additional information regarding copyright ownership. |
19 * limitations under the License. |
19 * limitations under the License. |
20 */ |
20 */ |
21 |
21 |
22 package com.sun.org.apache.xpath.internal.axes; |
22 package com.sun.org.apache.xpath.internal.axes; |
23 |
23 |
24 import java.util.ArrayList; |
|
25 |
|
26 import com.sun.org.apache.xml.internal.dtm.DTMIterator; |
24 import com.sun.org.apache.xml.internal.dtm.DTMIterator; |
27 import com.sun.org.apache.xml.internal.utils.WrappedRuntimeException; |
25 import com.sun.org.apache.xml.internal.utils.WrappedRuntimeException; |
|
26 import java.util.ArrayList; |
|
27 import java.util.List; |
28 |
28 |
29 /** |
29 /** |
30 * Pool of object of a given type to pick from to help memory usage |
30 * Pool of object of a given type to pick from to help memory usage |
31 * @xsl.usage internal |
31 * @xsl.usage internal |
32 */ |
32 */ |
40 private final DTMIterator m_orig; |
40 private final DTMIterator m_orig; |
41 |
41 |
42 /** |
42 /** |
43 * Stack of given objects this points to. |
43 * Stack of given objects this points to. |
44 */ |
44 */ |
45 private final ArrayList m_freeStack; |
45 private final List<DTMIterator> m_freeStack; |
46 |
46 |
47 /** |
47 /** |
48 * Constructor IteratorPool |
48 * Constructor IteratorPool |
49 * |
49 * |
50 * @param original The original iterator from which all others will be cloned. |
50 * @param original The original iterator from which all others will be cloned. |
51 */ |
51 */ |
52 public IteratorPool(DTMIterator original) |
52 public IteratorPool(DTMIterator original) |
53 { |
53 { |
54 m_orig = original; |
54 m_orig = original; |
55 m_freeStack = new ArrayList(); |
55 m_freeStack = new ArrayList<>(); |
56 } |
56 } |
57 |
57 |
58 /** |
58 /** |
59 * Get an instance of the given object in this pool |
59 * Get an instance of the given object in this pool |
60 * |
60 * |
71 return (DTMIterator)m_orig.clone(); |
71 return (DTMIterator)m_orig.clone(); |
72 } |
72 } |
73 else |
73 else |
74 { |
74 { |
75 // Remove object from end of free pool. |
75 // Remove object from end of free pool. |
76 DTMIterator result = (DTMIterator)m_freeStack.remove(m_freeStack.size() - 1); |
76 DTMIterator result = m_freeStack.remove(m_freeStack.size() - 1); |
77 return result; |
77 return result; |
78 } |
78 } |
79 } |
79 } |
80 |
80 |
81 /** |
81 /** |
100 } |
100 } |
101 } |
101 } |
102 else |
102 else |
103 { |
103 { |
104 // Remove object from end of free pool. |
104 // Remove object from end of free pool. |
105 DTMIterator result = (DTMIterator)m_freeStack.remove(m_freeStack.size() - 1); |
105 DTMIterator result = m_freeStack.remove(m_freeStack.size() - 1); |
106 return result; |
106 return result; |
107 } |
107 } |
108 } |
108 } |
109 |
109 |
110 /** |
110 /** |