aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-06-17 18:05:13 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-06-17 18:05:13 +0300
commitc9a2058361647d81b8303fc6892f8fb28a4288c5 (patch)
tree61973267975b4ee0b4cc7f3a577923d12b34aadb /src/util
parent7039dfafd6abd71e3407038122c0559fea6e1146 (diff)
downloadminetest-c9a2058361647d81b8303fc6892f8fb28a4288c5.tar.gz
minetest-c9a2058361647d81b8303fc6892f8fb28a4288c5.tar.bz2
minetest-c9a2058361647d81b8303fc6892f8fb28a4288c5.zip
Hopefully fix includes on mingw
Diffstat (limited to 'src/util')
-rw-r--r--src/util/numeric.cpp4
-rw-r--r--src/util/string.cpp4
-rw-r--r--src/util/timetaker.cpp4
3 files changed, 6 insertions, 6 deletions
diff --git a/src/util/numeric.cpp b/src/util/numeric.cpp
index d082cdb76..0ac812eb7 100644
--- a/src/util/numeric.cpp
+++ b/src/util/numeric.cpp
@@ -19,8 +19,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "numeric.h"
-#include "log.h"
-#include "constants.h" // BS, MAP_BLOCKSIZE
+#include "../log.h"
+#include "../constants.h" // BS, MAP_BLOCKSIZE
#include <iostream>
// Calculate the borders of a "d-radius" cube
diff --git a/src/util/string.cpp b/src/util/string.cpp
index ee4df849e..fb39a24c3 100644
--- a/src/util/string.cpp
+++ b/src/util/string.cpp
@@ -19,8 +19,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "string.h"
-#include "sha1.h"
-#include "base64.h"
+#include "../sha1.h"
+#include "../base64.h"
// Get an sha-1 hash of the player's name combined with
// the password entered. That's what the server uses as
diff --git a/src/util/timetaker.cpp b/src/util/timetaker.cpp
index 9cc87f3ea..52c618931 100644
--- a/src/util/timetaker.cpp
+++ b/src/util/timetaker.cpp
@@ -19,8 +19,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "timetaker.h"
-#include "gettime.h"
-#include "log.h"
+#include "../gettime.h"
+#include "../log.h"
#include <ostream>
TimeTaker::TimeTaker(const char *name, u32 *result)
33 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
/*
Minetest
Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef UTIL_CONTAINER_HEADER
#define UTIL_CONTAINER_HEADER

#include "../irrlichttypes.h"
#include <jmutex.h>
#include <jmutexautolock.h>
#include "../porting.h" // For sleep_ms
#include <list>
#include <vector>

/*
	Queue with unique values with fast checking of value existence
*/

template<typename Value>
class UniqueQueue
{
public:
	
	/*
		Does nothing if value is already queued.
		Return value:
			true: value added
			false: value already exists
	*/
	bool push_back(Value value)
	{
		// Check if already exists
		if(m_map.find(value) != m_map.end())
			return false;

		// Add
		m_map[value] = 0;
		m_list.push_back(value);
		
		return true;
	}

	Value pop_front()
	{
		typename std::list<Value>::iterator i = m_list.begin();
		Value value = *i;
		m_map.erase(value);
		m_list.erase(i);
		return value;
	}

	u32 size()
	{
		return m_map.size();
	}

private:
	std::map<Value, u8> m_map;
	std::list<Value> m_list;
};

#if 1
template<typename Key, typename Value>
class MutexedMap
{
public:
	MutexedMap()
	{
		m_mutex.Init();
		assert(m_mutex.IsInitialized());
	}
	
	void set(const Key &name, const Value &value)
	{
		JMutexAutoLock lock(m_mutex);

		m_values[name] = value;
	}
	
	bool get(const Key &name, Value *result)
	{
		JMutexAutoLock lock(m_mutex);

		typename std::map<Key, Value>::iterator n;
		n = m_values.find(name);

		if(n == m_values.end())
			return false;
		
		if(result != NULL)
			*result = n->second;
			
		return true;
	}

	std::list<Value> getValues()
	{
		std::list<Value> result;
		for(typename std::map<Key, Value>::iterator
				i = m_values.begin();
				i != m_values.end(); ++i){
			result.push_back(i->second);
		}