| @@ -3803,7 +3803,7 @@ YY_RULE_SETUP | |||
| while (*tmp != ' ' && *tmp != '\n' && *tmp != '\0') | |||
| tmp++; | |||
| String key(tmp2, (int)(tmp - tmp2)); | |||
| if (m_pp_defines.HasKey(key)) | |||
| if (m_pp_defines.has_key(key)) | |||
| { | |||
| m_pp_stack.Push(BlockIsTrue); | |||
| } | |||
| @@ -3828,7 +3828,7 @@ YY_RULE_SETUP | |||
| while (*tmp != ' ' && *tmp != '\n' && *tmp != '\0') | |||
| tmp++; | |||
| String key(tmp2, (int)(tmp - tmp2)); | |||
| if (m_pp_defines.HasKey(key)) | |||
| if (m_pp_defines.has_key(key)) | |||
| { | |||
| m_pp_stack.Push(BlockIsFalse); | |||
| BEGIN(PREPROCESSOR_COMMENT); | |||
| @@ -3870,7 +3870,7 @@ YY_RULE_SETUP | |||
| String key(tmp2, (int)(tmp - tmp2)); | |||
| Log::Debug("undef macro: ‘%s’\n", key.C()); | |||
| m_pp_defines.Remove(key); | |||
| m_pp_defines.remove(key); | |||
| } | |||
| YY_BREAK | |||
| case 373: | |||
| @@ -1,12 +1,14 @@ | |||
| %{ | |||
| // | |||
| // Lol Engine | |||
| // Lol Engine | |||
| // | |||
| // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
| // This program is free software; you can redistribute it and/or | |||
| // modify it under the terms of the Do What The Fuck You Want To | |||
| // Public License, Version 2, as published by Sam Hocevar. See | |||
| // http://www.wtfpl.net/ for more details. | |||
| // Copyright © 2010-2015 Sam Hocevar <sam@hocevar.net> | |||
| // | |||
| // This program is free software. It comes without any warranty, to | |||
| // the extent permitted by applicable law. You can redistribute it | |||
| // and/or modify it under the terms of the Do What the Fuck You Want | |||
| // to Public License, Version 2, as published by the WTFPL Task Force. | |||
| // See http://www.wtfpl.net/ for more details. | |||
| // | |||
| #if defined HAVE_CONFIG_H | |||
| @@ -532,7 +534,7 @@ typedef lol::LolFxParser::token_type token_type; | |||
| while (*tmp != ' ' && *tmp != '\n' && *tmp != '\0') | |||
| tmp++; | |||
| String key(tmp2, (int)(tmp - tmp2)); | |||
| if (m_pp_defines.HasKey(key)) | |||
| if (m_pp_defines.has_key(key)) | |||
| { | |||
| m_pp_stack.Push(BlockIsTrue); | |||
| } | |||
| @@ -554,7 +556,7 @@ typedef lol::LolFxParser::token_type token_type; | |||
| while (*tmp != ' ' && *tmp != '\n' && *tmp != '\0') | |||
| tmp++; | |||
| String key(tmp2, (int)(tmp - tmp2)); | |||
| if (m_pp_defines.HasKey(key)) | |||
| if (m_pp_defines.has_key(key)) | |||
| { | |||
| m_pp_stack.Push(BlockIsFalse); | |||
| BEGIN(PREPROCESSOR_COMMENT); | |||
| @@ -584,7 +586,7 @@ typedef lol::LolFxParser::token_type token_type; | |||
| String key(tmp2, (int)(tmp - tmp2)); | |||
| Log::Debug("undef macro: ‘%s’\n", key.C()); | |||
| m_pp_defines.Remove(key); | |||
| m_pp_defines.remove(key); | |||
| } | |||
| <PREPROCESSOR_COMMENT>^[ \t]*"#"[ \t]*(if|ifdef|ifndef)[ \t]+.*$ { | |||
| @@ -1,11 +1,13 @@ | |||
| // | |||
| // Lol Engine | |||
| // Lol Engine | |||
| // | |||
| // Copyright: (c) 2010-2014 Sam Hocevar <sam@hocevar.net> | |||
| // This program is free software; you can redistribute it and/or | |||
| // modify it under the terms of the Do What The Fuck You Want To | |||
| // Public License, Version 2, as published by Sam Hocevar. See | |||
| // http://www.wtfpl.net/ for more details. | |||
| // Copyright © 2010-2015 Sam Hocevar <sam@hocevar.net> | |||
| // | |||
| // This program is free software. It comes without any warranty, to | |||
| // the extent permitted by applicable law. You can redistribute it | |||
| // and/or modify it under the terms of the Do What the Fuck You Want | |||
| // to Public License, Version 2, as published by the WTFPL Task Force. | |||
| // See http://www.wtfpl.net/ for more details. | |||
| // | |||
| #include <lol/engine-internal.h> | |||
| @@ -197,15 +199,11 @@ Shader *Shader::Create(String const &name, String const &code) | |||
| { | |||
| lolfx_parser p(code); | |||
| if (!p.m_programs.HasKey("vert.glsl")) | |||
| { | |||
| ASSERT(false, "no vertex shader found in %s", name.C()); | |||
| } | |||
| ASSERT(p.m_programs.has_key("vert.glsl"), | |||
| "no vertex shader in %s", name.C()); | |||
| if (!p.m_programs.HasKey("frag.glsl")) | |||
| { | |||
| ASSERT(false, "no fragment shader found in %s", name.C()); | |||
| } | |||
| ASSERT(p.m_programs.has_key("frag.glsl"), | |||
| "no fragment shader in %s", name.C()); | |||
| String vert = p.m_programs["vert.glsl"]; | |||
| String frag = p.m_programs["frag.glsl"]; | |||
| @@ -452,7 +450,7 @@ Shader::Shader(String const &name, | |||
| flags |= (uint64_t)(uint16_t)index; | |||
| // TODO: this is here just in case. Remove this once everything has been correctly tested | |||
| #if _DEBUG | |||
| if (data->attrib_locations.HasKey(flags)) | |||
| if (data->attrib_locations.has_key(flags)) | |||
| { | |||
| Log::Error("error while parsing attribute semantics in %s\n", | |||
| name.C()); | |||
| @@ -469,7 +467,7 @@ Shader::Shader(String const &name, | |||
| int Shader::GetAttribCount() const | |||
| { | |||
| #if !defined __CELLOS_LV2__ | |||
| return data->attrib_locations.Count(); | |||
| return data->attrib_locations.count(); | |||
| #else | |||
| // TODO | |||
| return 0; | |||
| @@ -485,10 +483,10 @@ ShaderAttrib Shader::GetAttribLocation(VertexUsage usage, int index) const | |||
| #elif !defined __CELLOS_LV2__ | |||
| GLint l = -1; | |||
| if (!data->attrib_locations.TryGetValue(ret.m_flags, l)) | |||
| if (!data->attrib_locations.try_get(ret.m_flags, l)) | |||
| { | |||
| /* Only spit an error once, we don’t need to flood the console. */ | |||
| if (!data->attrib_errors.HasKey(ret.m_flags)) | |||
| if (!data->attrib_errors.has_key(ret.m_flags)) | |||
| { | |||
| Log::Error("attribute %s not found in shader %s\n", | |||
| usage.ToString().C(), data->m_name.C()); | |||
| @@ -1166,14 +1164,14 @@ String Shader::GetProgramOutVariableLocal(const ShaderProgram program) | |||
| //Shader Block implementation class ------------------------------------------- | |||
| void ShaderBlock::Add(const ShaderVariable parameter, String const &type, String const &name) | |||
| { | |||
| ASSERT(!m_parameters[parameter.ToScalar()].HasKey(name)); | |||
| ASSERT(!m_parameters[parameter.ToScalar()].has_key(name)); | |||
| m_parameters[parameter.ToScalar()][name] = type; | |||
| } | |||
| //---- | |||
| void ShaderBlock::AddCallParameters(const ShaderVariable type, map<String, String> const& variables, String& result) | |||
| { | |||
| array<String> keys = variables.Keys(); | |||
| array<String> keys = variables.keys(); | |||
| for (String key : keys) | |||
| { | |||
| if (result.Count() > 0) | |||
| @@ -1185,7 +1183,7 @@ void ShaderBlock::AddCallParameters(const ShaderVariable type, map<String, Strin | |||
| //---- | |||
| void ShaderBlock::AddDefinitionParameters(const ShaderVariable type, const ShaderProgram program, map<String, String>& variables, String& result) | |||
| { | |||
| array<String> keys = variables.Keys(); | |||
| array<String> keys = variables.keys(); | |||
| for (String key : keys) | |||
| { | |||
| if (result.Count() > 0) | |||
| @@ -1202,7 +1200,7 @@ void ShaderBlock::AddDefinitionParameters(const ShaderVariable type, const Shade | |||
| void ShaderBlock::Build(const ShaderProgram program, String& call, String& function) | |||
| { | |||
| ASSERT(m_name.Count()); | |||
| ASSERT(m_parameters[ShaderVariable::InOut].Count()); | |||
| ASSERT(m_parameters[ShaderVariable::InOut].count()); | |||
| //Build call in main | |||
| String call_name = String("Call_") + m_name; | |||
| @@ -1290,10 +1288,10 @@ String ShaderBuilder::AddSlotOutVariableLocal(const ShaderProgram program) | |||
| //---- | |||
| void ShaderBuilder::MergeParameters(map<String, String>& variables, map<String, String>& merged) | |||
| { | |||
| array<String> keys = variables.Keys(); | |||
| array<String> keys = variables.keys(); | |||
| for (String key : keys) | |||
| { | |||
| bool has_key = merged.HasKey(key); | |||
| bool has_key = merged.has_key(key); | |||
| //Key exists, check the type to make sure it's the same | |||
| ASSERT(!(has_key && merged[key] != variables[key])); | |||
| @@ -1309,7 +1307,7 @@ void ShaderBuilder::Build(String& code) | |||
| //Cleanup first | |||
| for (int prog = 0; prog < ShaderProgram::MAX; prog++) | |||
| for (int var = 0; var < ShaderVariable::MAX; var++) | |||
| m_parameters[prog][var].Empty(); | |||
| m_parameters[prog][var].empty(); | |||
| //Start building | |||
| for (int prog = 0; prog < ShaderProgram::MAX; prog++) | |||
| @@ -1334,7 +1332,7 @@ void ShaderBuilder::Build(String& code) | |||
| //Added shader variables | |||
| for (int var = 0; var < ShaderVariable::InOut; var++) | |||
| { | |||
| array<String> keys = m_parameters[prog][var].Keys(); | |||
| array<String> keys = m_parameters[prog][var].keys(); | |||
| if (keys.Count()) | |||
| { | |||
| code += String("//- ") + Shader::GetVariableQualifier((ShaderVariable)var) + " ----" + g_ret; | |||
| @@ -1373,7 +1371,7 @@ void ShaderBuilder::Build(String& code) | |||
| //Add local variables | |||
| int var = ShaderVariable::InOut; | |||
| array<String> keys = m_parameters[prog][var].Keys(); | |||
| array<String> keys = m_parameters[prog][var].keys(); | |||
| for (String key : keys) | |||
| { | |||
| if (keys.Count()) | |||
| @@ -1,11 +1,13 @@ | |||
| // | |||
| // Lol Engine | |||
| // Lol Engine | |||
| // | |||
| // Copyright: (c) 2010-2014 Sam Hocevar <sam@hocevar.net> | |||
| // This program is free software; you can redistribute it and/or | |||
| // modify it under the terms of the Do What The Fuck You Want To | |||
| // Public License, Version 2, as published by Sam Hocevar. See | |||
| // http://www.wtfpl.net/ for more details. | |||
| // Copyright © 2010-2015 Sam Hocevar <sam@hocevar.net> | |||
| // | |||
| // This program is free software. It comes without any warranty, to | |||
| // the extent permitted by applicable law. You can redistribute it | |||
| // and/or modify it under the terms of the Do What the Fuck You Want | |||
| // to Public License, Version 2, as published by the WTFPL Task Force. | |||
| // See http://www.wtfpl.net/ for more details. | |||
| // | |||
| #include <lol/engine-internal.h> | |||
| @@ -122,7 +124,7 @@ Image & Image::operator =(Image other) | |||
| Image::~Image() | |||
| { | |||
| for (int k : m_data->m_pixels.Keys()) | |||
| for (int k : m_data->m_pixels.keys()) | |||
| delete m_data->m_pixels[k]; | |||
| delete m_data; | |||
| @@ -156,7 +158,7 @@ void Image::SetSize(ivec2 size) | |||
| if (m_data->m_size != size) | |||
| { | |||
| for (int k : m_data->m_pixels.Keys()) | |||
| for (int k : m_data->m_pixels.keys()) | |||
| { | |||
| delete m_data->m_pixels[k]; | |||
| m_data->m_pixels[k] = nullptr; | |||
| @@ -204,7 +206,7 @@ void *Image::Lock2DHelper(PixelFormat T) | |||
| template<typename T> | |||
| void Image::Unlock2D(array2d<T> const &array) | |||
| { | |||
| ASSERT(m_data->m_pixels.HasKey((int)m_data->m_format)); | |||
| ASSERT(m_data->m_pixels.has_key((int)m_data->m_format)); | |||
| ASSERT(array.Data() == m_data->m_pixels[(int)m_data->m_format]->Data()); | |||
| } | |||
| @@ -231,7 +233,7 @@ void *Image::Lock() | |||
| void Image::Unlock(void const *pixels) | |||
| { | |||
| ASSERT(m_data->m_pixels.HasKey((int)m_data->m_format)); | |||
| ASSERT(m_data->m_pixels.has_key((int)m_data->m_format)); | |||
| ASSERT(pixels == m_data->m_pixels[(int)m_data->m_format]->Data()); | |||
| } | |||
| @@ -1,13 +1,15 @@ | |||
| // | |||
| // Lol Engine | |||
| // Lol Engine | |||
| // | |||
| // Copyright: (c) 2010-2014 Sam Hocevar <sam@hocevar.net> | |||
| // (c) 2013-2014 Benjamin "Touky" Huet <huet.benjamin@gmail.com> | |||
| // (c) 2013-2014 Guillaume Bittoun <guillaume.bittoun@gmail.com> | |||
| // This program is free software; you can redistribute it and/or | |||
| // modify it under the terms of the Do What The Fuck You Want To | |||
| // Public License, Version 2, as published by Sam Hocevar. See | |||
| // http://www.wtfpl.net/ for more details. | |||
| // Copyright © 2010-2015 Sam Hocevar <sam@hocevar.net> | |||
| // © 2013-2015 Benjamin "Touky" Huet <huet.benjamin@gmail.com> | |||
| // © 2013-2015 Guillaume Bittoun <guillaume.bittoun@gmail.com> | |||
| // | |||
| // This program is free software. It comes without any warranty, to | |||
| // the extent permitted by applicable law. You can redistribute it | |||
| // and/or modify it under the terms of the Do What the Fuck You Want | |||
| // to Public License, Version 2, as published by the WTFPL Task Force. | |||
| // See http://www.wtfpl.net/ for more details. | |||
| // | |||
| #pragma once | |||
| @@ -31,26 +33,26 @@ public: | |||
| m_root(nullptr), | |||
| m_count(0) | |||
| { | |||
| for (auto iterator : other) | |||
| this->Insert(iterator.key, iterator.value); | |||
| for (auto it : other) | |||
| this->insert(it.key, it.value); | |||
| } | |||
| avl_tree & operator=(avl_tree const & other) | |||
| { | |||
| this->Clear(); | |||
| this->clear(); | |||
| for (auto iterator : other) | |||
| this->Insert(iterator.key, iterator.value); | |||
| for (auto it : other) | |||
| this->insert(it.key, it.value); | |||
| return *this; | |||
| } | |||
| ~avl_tree() | |||
| { | |||
| this->Clear(); | |||
| this->clear(); | |||
| } | |||
| bool Insert(K const & key, V const & value) | |||
| bool insert(K const & key, V const & value) | |||
| { | |||
| if (!m_root) | |||
| { | |||
| @@ -59,7 +61,7 @@ public: | |||
| return true; | |||
| } | |||
| if(this->m_root->Insert(key, value)) | |||
| if(this->m_root->insert(key, value)) | |||
| { | |||
| ++this->m_count; | |||
| return true; | |||
| @@ -68,12 +70,12 @@ public: | |||
| return false; | |||
| } | |||
| bool Erase(K const & key) | |||
| bool erase(K const & key) | |||
| { | |||
| if (!m_root) | |||
| return false; | |||
| if(this->m_root->Erase(key)) | |||
| if(this->m_root->erase(key)) | |||
| { | |||
| --this->m_count; | |||
| return true; | |||
| @@ -82,15 +84,15 @@ public: | |||
| return false; | |||
| } | |||
| bool Exists(K const & key) | |||
| bool exists(K const & key) | |||
| { | |||
| if (!m_root) | |||
| return false; | |||
| return this->m_root->Exists(key); | |||
| return this->m_root->exists(key); | |||
| } | |||
| void Clear() | |||
| void clear() | |||
| { | |||
| if (this->m_root) | |||
| { | |||
| @@ -109,15 +111,15 @@ public: | |||
| this->m_count = 0; | |||
| } | |||
| bool TryGetValue(K const & key, V * & value_ptr) const | |||
| bool try_get(K const & key, V * & value_ptr) const | |||
| { | |||
| if (this->m_root) | |||
| return this->m_root->TryGetValue(key, value_ptr); | |||
| return this->m_root->try_get(key, value_ptr); | |||
| return false; | |||
| } | |||
| bool TryGetMin(K const * & key_ptr, V * & value_ptr) const | |||
| bool try_get_min(K const * & key_ptr, V * & value_ptr) const | |||
| { | |||
| tree_node * min_node = nullptr; | |||
| @@ -133,7 +135,7 @@ public: | |||
| return false; | |||
| } | |||
| bool TryGetMax(K const * & key_ptr, V * & value_ptr) const | |||
| bool try_get_max(K const * & key_ptr, V * & value_ptr) const | |||
| { | |||
| tree_node * max_node = nullptr; | |||
| @@ -149,27 +151,27 @@ public: | |||
| return false; | |||
| } | |||
| class Iterator; | |||
| class ConstIterator; | |||
| class iterator; | |||
| class const_iterator; | |||
| Iterator begin() | |||
| iterator begin() | |||
| { | |||
| tree_node * node = nullptr; | |||
| if (this->m_root) | |||
| this->m_root->GetMin(node); | |||
| return Iterator(node); | |||
| return iterator(node); | |||
| } | |||
| ConstIterator begin() const | |||
| const_iterator begin() const | |||
| { | |||
| tree_node * node = nullptr; | |||
| if (this->m_root) | |||
| this->m_root->GetMin(node); | |||
| return ConstIterator(node); | |||
| return const_iterator(node); | |||
| } | |||
| int GetCount() const | |||
| @@ -177,14 +179,14 @@ public: | |||
| return this->m_count; | |||
| } | |||
| Iterator end() | |||
| iterator end() | |||
| { | |||
| return Iterator(nullptr); | |||
| return iterator(nullptr); | |||
| } | |||
| ConstIterator end() const | |||
| const_iterator end() const | |||
| { | |||
| return ConstIterator(nullptr); | |||
| return const_iterator(nullptr); | |||
| } | |||
| protected: | |||
| @@ -214,7 +216,7 @@ protected: | |||
| /* Insert a value in tree and return true or update an existing value for | |||
| * the existing key and return false */ | |||
| bool Insert(K const & key, V const & value) | |||
| bool insert(K const & key, V const & value) | |||
| { | |||
| int i = -1 + (key < this->m_key) + 2 * (this->m_key < key); | |||
| @@ -224,13 +226,13 @@ protected: | |||
| return false; | |||
| } | |||
| bool created = false; | |||
| bool b_created = false; | |||
| if (this->m_child[i]) | |||
| created = this->m_child[i]->Insert(key, value); | |||
| b_created = this->m_child[i]->insert(key, value); | |||
| else | |||
| { | |||
| created = true; | |||
| b_created = true; | |||
| this->m_child[i] = new tree_node(key, value, &this->m_child[i]); | |||
| @@ -242,14 +244,14 @@ protected: | |||
| this->m_chain[i] = this->m_child[i]; | |||
| } | |||
| if (created) | |||
| if (b_created) | |||
| this->RebalanceIfNeeded(); | |||
| return created; | |||
| return b_created; | |||
| } | |||
| /* Erase a value in tree and return true or return false */ | |||
| bool Erase(K const & key) | |||
| bool erase(K const & key) | |||
| { | |||
| int i = -1 + (key < this->m_key) + 2 * (this->m_key < key); | |||
| @@ -259,7 +261,7 @@ protected: | |||
| delete this; | |||
| return true; | |||
| } | |||
| else if(this->m_child[i]->Erase(key)) | |||
| else if(this->m_child[i]->erase(key)) | |||
| { | |||
| this->RebalanceIfNeeded(); | |||
| return true; | |||
| @@ -268,7 +270,7 @@ protected: | |||
| return false; | |||
| } | |||
| bool TryGetValue(K const & key, V * & value_ptr) | |||
| bool try_get(K const & key, V * & value_ptr) | |||
| { | |||
| int i = -1 + (key < this->m_key) + 2 * (this->m_key < key); | |||
| @@ -279,12 +281,12 @@ protected: | |||
| } | |||
| if (this->m_child[i]) | |||
| return this->m_child[i]->TryGetValue(key, value_ptr); | |||
| return this->m_child[i]->try_get(key, value_ptr); | |||
| return false; | |||
| } | |||
| bool Exists(K const & key) | |||
| bool exists(K const & key) | |||
| { | |||
| int i = -1 + (key < this->m_key) + 2 * (this->m_key < key); | |||
| @@ -292,7 +294,7 @@ protected: | |||
| return true; | |||
| if (this->m_child[i]) | |||
| return this->m_child[i]->Exists(key); | |||
| return this->m_child[i]->exists(key); | |||
| return false; | |||
| } | |||
| @@ -450,43 +452,43 @@ public: | |||
| V & value; | |||
| }; | |||
| class Iterator | |||
| class iterator | |||
| { | |||
| public: | |||
| Iterator(tree_node * node) : | |||
| iterator(tree_node * node) : | |||
| m_node(node) | |||
| { | |||
| } | |||
| Iterator & operator++(int) | |||
| iterator & operator++(int) | |||
| { | |||
| this->m_node = this->m_node->get_next(); | |||
| return *this; | |||
| } | |||
| Iterator & operator--(int) | |||
| iterator & operator--(int) | |||
| { | |||
| this->m_node = this->m_node->get_previous(); | |||
| return *this; | |||
| } | |||
| Iterator operator++() | |||
| iterator operator++() | |||
| { | |||
| tree_node * ret = this->m_node; | |||
| this->m_node = this->m_node->GetNext(); | |||
| return Iterator(ret); | |||
| return iterator(ret); | |||
| } | |||
| Iterator operator--() | |||
| iterator operator--() | |||
| { | |||
| tree_node * ret = this->m_node; | |||
| this->m_node = this->m_node->GetPrevious(); | |||
| return Iterator(ret); | |||
| return iterator(ret); | |||
| } | |||
| OutputValue operator*() | |||
| @@ -494,7 +496,7 @@ public: | |||
| return OutputValue(this->m_node->GetKey(), this->m_node->GetValue()); | |||
| } | |||
| bool operator!=(Iterator const & that) const | |||
| bool operator!=(iterator const & that) const | |||
| { | |||
| return this->m_node != that.m_node; | |||
| } | |||
| @@ -516,43 +518,43 @@ public: | |||
| V const & value; | |||
| }; | |||
| class ConstIterator | |||
| class const_iterator | |||
| { | |||
| public: | |||
| ConstIterator(tree_node * node) : | |||
| const_iterator(tree_node * node) : | |||
| m_node(node) | |||
| { | |||
| } | |||
| ConstIterator & operator++(int) | |||
| const_iterator & operator++(int) | |||
| { | |||
| this->m_node = this->m_node->get_next(); | |||
| return *this; | |||
| } | |||
| ConstIterator & operator--(int) | |||
| const_iterator & operator--(int) | |||
| { | |||
| this->m_node = this->m_node->get_previous(); | |||
| return *this; | |||
| } | |||
| ConstIterator operator++() | |||
| const_iterator operator++() | |||
| { | |||
| tree_node * ret = this->m_node; | |||
| this->m_node = this->m_node->GetNext(); | |||
| return ConstIterator(ret); | |||
| return const_iterator(ret); | |||
| } | |||
| ConstIterator operator--() | |||
| const_iterator operator--() | |||
| { | |||
| tree_node * ret = this->m_node; | |||
| this->m_node = this->m_node->GetPrevious(); | |||
| return ConstIterator(ret); | |||
| return const_iterator(ret); | |||
| } | |||
| ConstOutputValue operator*() | |||
| @@ -560,7 +562,7 @@ public: | |||
| return ConstOutputValue(this->m_node->GetKey(), this->m_node->GetValue()); | |||
| } | |||
| bool operator!=(ConstIterator const & that) const | |||
| bool operator!=(const_iterator const & that) const | |||
| { | |||
| return this->m_node != that.m_node; | |||
| } | |||
| @@ -1,11 +1,14 @@ | |||
| // | |||
| // Lol Engine | |||
| // Lol Engine | |||
| // | |||
| // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
| // This program is free software; you can redistribute it and/or | |||
| // modify it under the terms of the Do What The Fuck You Want To | |||
| // Public License, Version 2, as published by Sam Hocevar. See | |||
| // http://www.wtfpl.net/ for more details. | |||
| // Copyright © 2010-2015 Sam Hocevar <sam@hocevar.net> | |||
| // © 2013-2015 Guillaume Bittoun <guillaume.bittoun@gmail.com> | |||
| // | |||
| // This program is free software. It comes without any warranty, to | |||
| // the extent permitted by applicable law. You can redistribute it | |||
| // and/or modify it under the terms of the Do What the Fuck You Want | |||
| // to Public License, Version 2, as published by the WTFPL Task Force. | |||
| // See http://www.wtfpl.net/ for more details. | |||
| // | |||
| #pragma once | |||
| @@ -49,15 +52,15 @@ public: | |||
| { | |||
| /* FIXME: we all know this isn’t thread safe. But is it really | |||
| * a big deal? */ | |||
| static map<int64_t, String> map; | |||
| static map<int64_t, String> enum_map; | |||
| static bool ready = false; | |||
| if (!ready) | |||
| map = BuildEnumMap(BASE::GetDescription(), BASE::GetCustomString()); | |||
| enum_map = BuildEnumMap(BASE::GetDescription(), BASE::GetCustomString()); | |||
| ready = true; | |||
| if (map.HasKey((int64_t)m_value)) | |||
| return map[(int64_t)m_value]; | |||
| if (enum_map.has_key((int64_t)m_value)) | |||
| return enum_map[(int64_t)m_value]; | |||
| return "<invalid enum>"; | |||
| } | |||
| @@ -1,12 +1,14 @@ | |||
| // | |||
| // Lol Engine | |||
| // Lol Engine | |||
| // | |||
| // Copyright: (c) 2010-2015 Sam Hocevar <sam@hocevar.net> | |||
| // (c) 2013-2015 Guillaume Bittoun <guillaume.bittoun@gmail.com> | |||
| // This program is free software; you can redistribute it and/or | |||
| // modify it under the terms of the Do What The Fuck You Want To | |||
| // Public License, Version 2, as published by Sam Hocevar. See | |||
| // http://www.wtfpl.net/ for more details. | |||
| // Copyright © 2010-2015 Sam Hocevar <sam@hocevar.net> | |||
| // © 2013-2015 Guillaume Bittoun <guillaume.bittoun@gmail.com> | |||
| // | |||
| // This program is free software. It comes without any warranty, to | |||
| // the extent permitted by applicable law. You can redistribute it | |||
| // and/or modify it under the terms of the Do What the Fuck You Want | |||
| // to Public License, Version 2, as published by the WTFPL Task Force. | |||
| // See http://www.wtfpl.net/ for more details. | |||
| // | |||
| #pragma once | |||
| @@ -37,7 +39,7 @@ public: | |||
| { | |||
| /* Look for the hash in our table and return the value. */ | |||
| V *value_ptr = nullptr; | |||
| bool found = m_tree.TryGetValue(key, value_ptr); | |||
| bool found = m_tree.try_get(key, value_ptr); | |||
| ASSERT(found, "trying to read a nonexistent key in map"); | |||
| @@ -51,12 +53,12 @@ public: | |||
| K typed_key(key); | |||
| V *value_ptr = nullptr; | |||
| bool found = m_tree.TryGetValue(key, value_ptr); | |||
| bool found = m_tree.try_get(key, value_ptr); | |||
| if (!found) | |||
| { | |||
| /* If not found, insert a new value. */ | |||
| m_tree.Insert(typed_key, V()); | |||
| found = m_tree.TryGetValue(key, value_ptr); | |||
| m_tree.insert(typed_key, V()); | |||
| found = m_tree.try_get(key, value_ptr); | |||
| } | |||
| /* This may happen if the key operator < does not behave as | |||
| @@ -67,25 +69,25 @@ public: | |||
| } | |||
| template <typename E> | |||
| inline void Remove(E const &key) | |||
| inline void remove(E const &key) | |||
| { | |||
| K typed_key(key); | |||
| m_tree.Erase(typed_key); | |||
| m_tree.erase(typed_key); | |||
| } | |||
| template <typename E> | |||
| inline bool HasKey(E const &key) | |||
| inline bool has_key(E const &key) | |||
| { | |||
| K typed_key(key); | |||
| return m_tree.Exists(typed_key); | |||
| return m_tree.exists(typed_key); | |||
| } | |||
| template <typename E> | |||
| inline bool TryGetValue(E const &key, V& value) | |||
| inline bool try_get(E const &key, V& value) | |||
| { | |||
| K typed_key(key); | |||
| V *value_ptr; | |||
| if (m_tree.TryGetValue(typed_key, value_ptr)) | |||
| if (m_tree.try_get(typed_key, value_ptr)) | |||
| { | |||
| value = *value_ptr; | |||
| return true; | |||
| @@ -94,7 +96,7 @@ public: | |||
| return false; | |||
| } | |||
| array<K> Keys() const | |||
| array<K> keys() const | |||
| { | |||
| array<K> ret; | |||
| @@ -104,18 +106,17 @@ public: | |||
| return ret; | |||
| } | |||
| inline ptrdiff_t Count() const | |||
| inline ptrdiff_t count() const | |||
| { | |||
| return m_tree.GetCount(); | |||
| } | |||
| inline void Empty() | |||
| inline void empty() | |||
| { | |||
| m_tree.Clear(); | |||
| m_tree.clear(); | |||
| } | |||
| private: | |||
| avl_tree<K, V> m_tree; | |||
| }; | |||
| @@ -1,13 +1,15 @@ | |||
| // | |||
| // Lol Engine | |||
| // Lol Engine | |||
| // | |||
| // Copyright: (c) 2010-2014 Sam Hocevar <sam@hocevar.net> | |||
| // (c) 2013-2014 Benjamin "Touky" Huet <huet.benjamin@gmail.com> | |||
| // (c) 2013-2014 Guillaume Bittoun <guillaume.bittoun@gmail.com> | |||
| // This program is free software; you can redistribute it and/or | |||
| // modify it under the terms of the Do What The Fuck You Want To | |||
| // Public License, Version 2, as published by Sam Hocevar. See | |||
| // http://www.wtfpl.net/ for more details. | |||
| // Copyright © 2010-2015 Sam Hocevar <sam@hocevar.net> | |||
| // © 2013-2015 Benjamin "Touky" Huet <huet.benjamin@gmail.com> | |||
| // © 2013-2015 Guillaume Bittoun <guillaume.bittoun@gmail.com> | |||
| // | |||
| // This program is free software. It comes without any warranty, to | |||
| // the extent permitted by applicable law. You can redistribute it | |||
| // and/or modify it under the terms of the Do What the Fuck You Want | |||
| // to Public License, Version 2, as published by the WTFPL Task Force. | |||
| // See http://www.wtfpl.net/ for more details. | |||
| // | |||
| #include <lol/engine-internal.h> | |||
| @@ -38,40 +40,40 @@ lolunit_declare_fixture(AvlTreeTest) | |||
| { | |||
| test_tree tree; | |||
| lolunit_assert_equal(tree.Insert(1, 1), true); | |||
| lolunit_assert_equal(tree.Insert(2, 3), true); | |||
| lolunit_assert_equal(tree.Insert(2, 0), false); | |||
| lolunit_assert_equal(tree.insert(1, 1), true); | |||
| lolunit_assert_equal(tree.insert(2, 3), true); | |||
| lolunit_assert_equal(tree.insert(2, 0), false); | |||
| } | |||
| lolunit_declare_test(AvlTreeBalanceCheck) | |||
| { | |||
| test_tree tree; | |||
| lolunit_assert_equal(tree.Insert(10, 1), true); | |||
| lolunit_assert_equal(tree.insert(10, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 0); | |||
| lolunit_assert_equal(tree.Insert(20, 1), true); | |||
| lolunit_assert_equal(tree.insert(20, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 1); | |||
| lolunit_assert_equal(tree.Insert(30, 1), true); | |||
| lolunit_assert_equal(tree.insert(30, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 0); | |||
| lolunit_assert_equal(tree.Insert(00, 1), true); | |||
| lolunit_assert_equal(tree.insert(0, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), -1); | |||
| lolunit_assert_equal(tree.Insert(-10, 1), true); | |||
| lolunit_assert_equal(tree.insert(-10, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), -1); | |||
| lolunit_assert_equal(tree.Insert(-20, 1), true); | |||
| lolunit_assert_equal(tree.insert(-20, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 0); | |||
| lolunit_assert_equal(tree.Insert(-20, 1), false); | |||
| lolunit_assert_equal(tree.insert(-20, 1), false); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 0); | |||
| lolunit_assert_equal(tree.Insert(11, 1), true); | |||
| lolunit_assert_equal(tree.insert(11, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 1); | |||
| lolunit_assert_equal(tree.Insert(13, 2), true); | |||
| lolunit_assert_equal(tree.insert(13, 2), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 1); | |||
| } | |||
| @@ -79,18 +81,18 @@ lolunit_declare_fixture(AvlTreeTest) | |||
| { | |||
| test_tree tree; | |||
| lolunit_assert_equal(tree.Insert(10, 1), true); | |||
| lolunit_assert_equal(tree.insert(10, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 0); | |||
| lolunit_assert_equal(tree.Insert(20, 1), true); | |||
| lolunit_assert_equal(tree.insert(20, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 1); | |||
| lolunit_assert_equal(tree.Insert(30, 1), true); | |||
| lolunit_assert_equal(tree.insert(30, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 0); | |||
| lolunit_assert_equal(tree.GetCount(), 3); | |||
| lolunit_assert_equal(tree.Erase(30), true); | |||
| lolunit_assert_equal(tree.erase(30), true); | |||
| int test = 0; | |||
| @@ -101,11 +103,11 @@ lolunit_declare_fixture(AvlTreeTest) | |||
| } | |||
| lolunit_assert_equal(tree.GetCount(), 2); | |||
| lolunit_assert_equal(tree.Insert(30, 1), true); | |||
| lolunit_assert_equal(tree.insert(30, 1), true); | |||
| lolunit_assert_equal(tree.Erase(20), true); | |||
| lolunit_assert_equal(tree.Insert(20, 1), true); | |||
| lolunit_assert_equal(tree.Exists(10), true); | |||
| lolunit_assert_equal(tree.erase(20), true); | |||
| lolunit_assert_equal(tree.insert(20, 1), true); | |||
| lolunit_assert_equal(tree.exists(10), true); | |||
| test = 0; | |||
| @@ -120,31 +122,31 @@ lolunit_declare_fixture(AvlTreeTest) | |||
| { | |||
| test_tree tree; | |||
| lolunit_assert_equal(tree.Insert(10, 1), true); | |||
| lolunit_assert_equal(tree.insert(10, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 0); | |||
| lolunit_assert_equal(tree.Insert(20, 1), true); | |||
| lolunit_assert_equal(tree.insert(20, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 1); | |||
| lolunit_assert_equal(tree.Erase(10), true); | |||
| lolunit_assert_equal(tree.Exists(20), true); | |||
| lolunit_assert_equal(tree.Exists(10), false); | |||
| lolunit_assert_equal(tree.erase(10), true); | |||
| lolunit_assert_equal(tree.exists(20), true); | |||
| lolunit_assert_equal(tree.exists(10), false); | |||
| lolunit_assert_equal(tree.Insert(10, 1), true); | |||
| lolunit_assert_equal(tree.insert(10, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), -1); | |||
| lolunit_assert_equal(tree.Insert(30, 1), true); | |||
| lolunit_assert_equal(tree.insert(30, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 0); | |||
| lolunit_assert_equal(tree.Insert(40, 1), true); | |||
| lolunit_assert_equal(tree.insert(40, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 1); | |||
| lolunit_assert_equal(tree.Insert(50, 1), true); | |||
| lolunit_assert_equal(tree.insert(50, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 1); | |||
| lolunit_assert_equal(tree.Erase(30), true); | |||
| lolunit_assert_equal(tree.Exists(40), true); | |||
| lolunit_assert_equal(tree.Exists(50), true); | |||
| lolunit_assert_equal(tree.erase(30), true); | |||
| lolunit_assert_equal(tree.exists(40), true); | |||
| lolunit_assert_equal(tree.exists(50), true); | |||
| } | |||
| @@ -152,45 +154,45 @@ lolunit_declare_fixture(AvlTreeTest) | |||
| { | |||
| test_tree tree; | |||
| lolunit_assert_equal(tree.Insert(10, 1), true); | |||
| lolunit_assert_equal(tree.insert(10, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 0); | |||
| lolunit_assert_equal(tree.Insert(20, 1), true); | |||
| lolunit_assert_equal(tree.insert(20, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 1); | |||
| lolunit_assert_equal(tree.Insert(30, 1), true); | |||
| lolunit_assert_equal(tree.insert(30, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 0); | |||
| lolunit_assert_equal(tree.Insert(00, 1), true); | |||
| lolunit_assert_equal(tree.insert(0, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), -1); | |||
| lolunit_assert_equal(tree.Insert(-10, 1), true); | |||
| lolunit_assert_equal(tree.insert(-10, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), -1); | |||
| lolunit_assert_equal(tree.Insert(-20, 1), true); | |||
| lolunit_assert_equal(tree.insert(-20, 1), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 0); | |||
| lolunit_assert_equal(tree.Insert(-20, 1), false); | |||
| lolunit_assert_equal(tree.insert(-20, 1), false); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 0); | |||
| lolunit_assert_equal(tree.Insert(11, 2), true); | |||
| lolunit_assert_equal(tree.insert(11, 2), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 1); | |||
| lolunit_assert_equal(tree.Insert(13, 3), true); | |||
| lolunit_assert_equal(tree.insert(13, 3), true); | |||
| lolunit_assert_equal(tree.GetRootBalance(), 1); | |||
| int * value_ptr = nullptr; | |||
| lolunit_assert_equal(tree.TryGetValue(-10, value_ptr), true); | |||
| lolunit_assert_equal(tree.try_get(-10, value_ptr), true); | |||
| lolunit_assert_equal(*value_ptr, 1); | |||
| lolunit_assert_equal(tree.TryGetValue(11, value_ptr), true); | |||
| lolunit_assert_equal(tree.try_get(11, value_ptr), true); | |||
| lolunit_assert_equal(*value_ptr, 2); | |||
| lolunit_assert_equal(tree.TryGetValue(13, value_ptr), true); | |||
| lolunit_assert_equal(tree.try_get(13, value_ptr), true); | |||
| lolunit_assert_equal(*value_ptr, 3); | |||
| lolunit_assert_equal(tree.TryGetValue(67, value_ptr), false); | |||
| lolunit_assert_equal(tree.try_get(67, value_ptr), false); | |||
| lolunit_assert_equal(*value_ptr, 3); | |||
| } | |||
| @@ -199,7 +201,7 @@ lolunit_declare_fixture(AvlTreeTest) | |||
| test_tree tree; | |||
| for (int i = 1 ; i < 100 ; ++i) | |||
| tree.Insert(i, 2 * i + i % 3); | |||
| tree.insert(i, 2 * i + i % 3); | |||
| int tmp = 0; | |||
| @@ -218,7 +220,7 @@ lolunit_declare_fixture(AvlTreeTest) | |||
| test_tree tree; | |||
| for (int i = 1 ; i < 100 ; ++i) | |||
| tree.Insert(i, 2 * i + i % 3); | |||
| tree.insert(i, 2 * i + i % 3); | |||
| test_tree other = tree; | |||
| @@ -239,10 +241,10 @@ lolunit_declare_fixture(AvlTreeTest) | |||
| avl_tree<int, int> test1, test2; | |||
| for (int i = 0 ; i < 10 ; ++i) | |||
| test1.Insert(i, 2*i); | |||
| test1.insert(i, 2*i); | |||
| for (int i = 10 ; i < 15 ; ++i) | |||
| test2.Insert(i, 3*i); | |||
| test2.insert(i, 3*i); | |||
| lolunit_assert_equal(test1.GetCount(), 10); | |||
| lolunit_assert_equal(test2.GetCount(), 5); | |||
| @@ -1,11 +1,13 @@ | |||
| // | |||
| // Lol Engine | |||
| // Lol Engine | |||
| // | |||
| // Copyright: (c) 2010-2014 Sam Hocevar <sam@hocevar.net> | |||
| // This program is free software; you can redistribute it and/or | |||
| // modify it under the terms of the Do What The Fuck You Want To | |||
| // Public License, Version 2, as published by Sam Hocevar. See | |||
| // http://www.wtfpl.net/ for more details. | |||
| // Copyright © 2010-2015 Sam Hocevar <sam@hocevar.net> | |||
| // | |||
| // This program is free software. It comes without any warranty, to | |||
| // the extent permitted by applicable law. You can redistribute it | |||
| // and/or modify it under the terms of the Do What the Fuck You Want | |||
| // to Public License, Version 2, as published by the WTFPL Task Force. | |||
| // See http://www.wtfpl.net/ for more details. | |||
| // | |||
| #include <lol/engine-internal.h> | |||
| @@ -50,9 +52,9 @@ lolunit_declare_fixture(MapTest) | |||
| m[0] = 1; | |||
| m[2] = 2; | |||
| lolunit_assert(m.HasKey(0)); | |||
| lolunit_assert(!m.HasKey(1)); | |||
| lolunit_assert(m.HasKey(2)); | |||
| lolunit_assert(m.has_key(0)); | |||
| lolunit_assert(!m.has_key(1)); | |||
| lolunit_assert(m.has_key(2)); | |||
| } | |||
| lolunit_declare_test(StringMap) | |||