Skip to content
Snippets Groups Projects
Commit 8119bfff authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

Fixed copy errors when using dictionary views.

parent ea1dd7f1
No related branches found
No related tags found
No related merge requests found
......@@ -63,8 +63,10 @@ public class DoubleArrayDictionary implements Serializable {
* @param dictionary dictionary to use for initializing entries
*/
public DoubleArrayDictionary(final DoubleArrayDictionary dictionary) {
this(DEFAULT_INITIAL_CAPACITY + dictionary.data.size());
for (final Entry entry : dictionary.data) {
// take care to call dictionary.getData() and not use dictionary.data,
// otherwise we get an empty dictionary when using a DoubleArrayDictionary.view
this(DEFAULT_INITIAL_CAPACITY + dictionary.getData().size());
for (final Entry entry : dictionary.getData()) {
// we don't call put(key, value) to avoid the overhead of the unneeded call to remove(key)
data.add(new Entry(entry.getKey(), entry.getValue()));
}
......
......@@ -70,8 +70,10 @@ public class FieldArrayDictionary<T extends CalculusFieldElement<T>> {
* @param dictionary dictionary to use for initializing entries
*/
public FieldArrayDictionary(final FieldArrayDictionary<T> dictionary) {
this(dictionary.getField(), DEFAULT_INITIAL_CAPACITY + dictionary.data.size());
for (final Entry entry : dictionary.data) {
// take care to call dictionary.getData() and not use dictionary.data,
// otherwise we get an empty dictionary when using a FieldArrayDictionary.view
this(dictionary.getField(), DEFAULT_INITIAL_CAPACITY + dictionary.getData().size());
for (final Entry entry : dictionary.getData()) {
// we don't call put(key, value) to avoid the overhead of the unneeded call to remove(key)
data.add(new Entry(entry.getKey(), entry.getValue()));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment