diff options
author | chai <chaifix@163.com> | 2021-10-22 23:59:54 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-22 23:59:54 +0800 |
commit | 4dafefe46a72ba47468b13d011f8299055081b0f (patch) | |
tree | 2a85835ec4d74fecf3815397b384cefe39d31f56 /Runtime/Lua/LuaBind/signal/remove_from_container.h | |
parent | 1f18d2afec632aa9361079ca3bcb5a7f2d73db3a (diff) |
*LuaBind
Diffstat (limited to 'Runtime/Lua/LuaBind/signal/remove_from_container.h')
-rw-r--r-- | Runtime/Lua/LuaBind/signal/remove_from_container.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Runtime/Lua/LuaBind/signal/remove_from_container.h b/Runtime/Lua/LuaBind/signal/remove_from_container.h new file mode 100644 index 0000000..9fdc442 --- /dev/null +++ b/Runtime/Lua/LuaBind/signal/remove_from_container.h @@ -0,0 +1,32 @@ +// Aseprite Base Library
+// Copyright (c) 2001-2013 David Capello
+//
+// This file is released under the terms of the MIT license.
+// Read LICENSE.txt for more information.
+
+#ifndef BASE_REMOVE_FROM_CONTAINER_H_INCLUDED
+#define BASE_REMOVE_FROM_CONTAINER_H_INCLUDED
+#pragma once
+
+namespace base {
+
+// Removes all ocurrences of the specified element from the STL container.
+template<typename ContainerType>
+void remove_from_container(ContainerType& container,
+ typename ContainerType::const_reference element)
+{
+ for (typename ContainerType::iterator
+ it = container.begin(),
+ end = container.end(); it != end; ) {
+ if (*it == element) {
+ it = container.erase(it);
+ end = container.end();
+ }
+ else
+ ++it;
+ }
+}
+
+}
+
+#endif
|