array.h
1 /*************************************************************************/
2 /* array.h */
3 /*************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* http://www.godotengine.org */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
9 /* */
10 /* Permission is hereby granted, free of charge, to any person obtaining */
11 /* a copy of this software and associated documentation files (the */
12 /* "Software"), to deal in the Software without restriction, including */
13 /* without limitation the rights to use, copy, modify, merge, publish, */
14 /* distribute, sublicense, and/or sell copies of the Software, and to */
15 /* permit persons to whom the Software is furnished to do so, subject to */
16 /* the following conditions: */
17 /* */
18 /* The above copyright notice and this permission notice shall be */
19 /* included in all copies or substantial portions of the Software. */
20 /* */
21 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
22 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
23 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
24 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
25 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
26 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
27 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
28 /*************************************************************************/
29 #ifndef ARRAY_H
30 #define ARRAY_H
31 
32 #include "typedefs.h"
33 class Variant;
34 class ArrayPrivate;
35 class Object;
36 class StringName;
37 
38 class Array {
39 
40  mutable ArrayPrivate *_p;
41  void _ref(const Array& p_from) const;
42  void _unref() const;
43 
44 public:
45 
46  Variant& operator[](int p_idx);
47  const Variant& operator[](int p_idx) const;
48 
49  void set(int p_idx,const Variant& p_value);
50  const Variant& get(int p_idx) const;
51 
52  int size() const;
53  bool empty() const;
54  void clear();
55 
56  bool is_shared() const;
57 
58  bool operator==(const Array& p_array) const;
59 
60  uint32_t hash() const;
61  void operator=(const Array& p_array);
62 
63  void push_back(const Variant& p_value);
64  _FORCE_INLINE_ void append(const Variant& p_value) { push_back(p_value); } //for python compatibility
65  Error resize(int p_new_size);
66 
67  void insert(int p_pos, const Variant& p_value);
68  void remove(int p_pos);
69 
70  void sort();
71  void sort_custom(Object *p_obj,const StringName& p_function);
72  void invert();
73 
74  int find(const Variant& p_value) const;
75 
76  void erase(const Variant& p_value);
77 
78  void push_front(const Variant& p_value);
79  void pop_back();
80  void pop_front();
81 
82  Array(const Array& p_from);
83  Array(bool p_shared=false);
84  ~Array();
85 
86 };
87 
88 #endif // ARRAY_H
Definition: array.h:38
Definition: array.cpp:35
Definition: variant.h:74
Definition: string_db.h:48
Definition: object.h:317