summaryrefslogtreecommitdiff
path: root/core/array.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/array.cpp')
-rw-r--r--core/array.cpp34
1 files changed, 14 insertions, 20 deletions
diff --git a/core/array.cpp b/core/array.cpp
index 683a43e3d0..b9c8f543da 100644
--- a/core/array.cpp
+++ b/core/array.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,6 @@ struct ArrayPrivate {
SafeRefCount refcount;
Vector<Variant> array;
- bool shared;
};
void Array::_ref(const Array& p_from) const {
@@ -54,20 +53,9 @@ void Array::_ref(const Array& p_from) const {
_unref();
- if (_fp->shared) {
+ _p = p_from._p;
- _p = p_from._p;
- } else {
-
- _p = memnew( ArrayPrivate );
- _p->shared=false;
- _p->refcount.init();
- _p->array=_fp->array;
-
- if (_fp->refcount.unref())
- memdelete(_fp);
- }
}
void Array::_unref() const {
@@ -106,10 +94,6 @@ void Array::clear() {
_p->array.clear();
}
-bool Array::is_shared() const {
-
- return _p->shared;
-}
bool Array::operator==(const Array& p_array) const {
@@ -150,6 +134,16 @@ void Array::erase(const Variant& p_value) {
_p->array.erase(p_value);
}
+Variant Array::front() const {
+ ERR_FAIL_COND_V(_p->array.size() == 0, Variant());
+ return operator[](0);
+}
+
+Variant Array::back() const {
+ ERR_FAIL_COND_V(_p->array.size() == 0, Variant());
+ return operator[](_p->array.size() - 1);
+}
+
int Array::find(const Variant& p_value, int p_from) const {
return _p->array.find(p_value, p_from);
@@ -306,11 +300,11 @@ Array::Array(const Array& p_from) {
_ref(p_from);
}
-Array::Array(bool p_shared) {
+Array::Array() {
_p = memnew( ArrayPrivate );
_p->refcount.init();
- _p->shared=p_shared;
+
}
Array::~Array() {