1 /* |
1 /* |
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
75 extern "C" { |
75 extern "C" { |
76 typedef int (*_sort_Fn)(const void *, const void *); |
76 typedef int (*_sort_Fn)(const void *, const void *); |
77 } |
77 } |
78 |
78 |
79 class GenericGrowableArray : public ResourceObj { |
79 class GenericGrowableArray : public ResourceObj { |
|
80 friend class VMStructs; |
|
81 |
80 protected: |
82 protected: |
81 int _len; // current length |
83 int _len; // current length |
82 int _max; // maximum length |
84 int _max; // maximum length |
83 Arena* _arena; // Indicates where allocation occurs: |
85 Arena* _arena; // Indicates where allocation occurs: |
84 // 0 means default ResourceArea |
86 // 0 means default ResourceArea |
134 return (void*)resource_allocate_bytes(thread, elementSize * _max); |
136 return (void*)resource_allocate_bytes(thread, elementSize * _max); |
135 } |
137 } |
136 }; |
138 }; |
137 |
139 |
138 template<class E> class GrowableArray : public GenericGrowableArray { |
140 template<class E> class GrowableArray : public GenericGrowableArray { |
|
141 friend class VMStructs; |
|
142 |
139 private: |
143 private: |
140 E* _data; // data array |
144 E* _data; // data array |
141 |
145 |
142 void grow(int j); |
146 void grow(int j); |
143 void raw_at_put_grow(int i, const E& p, const E& fill); |
147 void raw_at_put_grow(int i, const E& p, const E& fill); |