mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r13575) -Codechange: Move small vector to core since it fits better in there
-Codechange: convert smallvector from struct to class
This commit is contained in:
parent
c4cc5cdf3b
commit
2f65d35ead
|
@ -1451,6 +1451,10 @@
|
||||||
RelativePath=".\..\src\slope_type.h"
|
RelativePath=".\..\src\slope_type.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\core\smallvec_type.hpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\core\sort_func.hpp"
|
RelativePath=".\..\src\core\sort_func.hpp"
|
||||||
>
|
>
|
||||||
|
@ -2403,10 +2407,6 @@
|
||||||
RelativePath=".\..\src\misc\hashtable.hpp"
|
RelativePath=".\..\src\misc\hashtable.hpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\..\src\misc\smallvec.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\misc\str.hpp"
|
RelativePath=".\..\src\misc\str.hpp"
|
||||||
>
|
>
|
||||||
|
|
|
@ -1448,6 +1448,10 @@
|
||||||
RelativePath=".\..\src\slope_type.h"
|
RelativePath=".\..\src\slope_type.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\core\smallvec_type.hpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\core\sort_func.hpp"
|
RelativePath=".\..\src\core\sort_func.hpp"
|
||||||
>
|
>
|
||||||
|
@ -2400,10 +2404,6 @@
|
||||||
RelativePath=".\..\src\misc\hashtable.hpp"
|
RelativePath=".\..\src\misc\hashtable.hpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\..\src\misc\smallvec.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\misc\str.hpp"
|
RelativePath=".\..\src\misc\str.hpp"
|
||||||
>
|
>
|
||||||
|
|
|
@ -288,6 +288,7 @@ signs_func.h
|
||||||
signs_type.h
|
signs_type.h
|
||||||
slope_func.h
|
slope_func.h
|
||||||
slope_type.h
|
slope_type.h
|
||||||
|
core/smallvec_type.hpp
|
||||||
core/sort_func.hpp
|
core/sort_func.hpp
|
||||||
sortlist_type.h
|
sortlist_type.h
|
||||||
sound_func.h
|
sound_func.h
|
||||||
|
@ -552,7 +553,6 @@ misc/dbg_helpers.cpp
|
||||||
misc/dbg_helpers.h
|
misc/dbg_helpers.h
|
||||||
misc/fixedsizearray.hpp
|
misc/fixedsizearray.hpp
|
||||||
misc/hashtable.hpp
|
misc/hashtable.hpp
|
||||||
misc/smallvec.h
|
|
||||||
misc/str.hpp
|
misc/str.hpp
|
||||||
misc/strapi.hpp
|
misc/strapi.hpp
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
/** @file smallvec.h Simple vector class that allows allocating an item without the need to copy this->data needlessly. */
|
/** @file smallvec_type.hpp Simple vector class that allows allocating an item without the need to copy this->data needlessly. */
|
||||||
|
|
||||||
#ifndef SMALLVEC_H
|
#ifndef SMALLVEC_TYPE_HPP
|
||||||
#define SMALLVEC_H
|
#define SMALLVEC_TYPE_HPP
|
||||||
|
|
||||||
#include "../core/alloc_func.hpp"
|
#include "alloc_func.hpp"
|
||||||
#include "../core/math_func.hpp"
|
#include "math_func.hpp"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple vector template class.
|
* Simple vector template class.
|
||||||
|
@ -19,11 +19,13 @@
|
||||||
* @param S The steps of allocation
|
* @param S The steps of allocation
|
||||||
*/
|
*/
|
||||||
template <typename T, uint S>
|
template <typename T, uint S>
|
||||||
struct SmallVector {
|
class SmallVector {
|
||||||
|
protected:
|
||||||
T *data; ///< The pointer to the first item
|
T *data; ///< The pointer to the first item
|
||||||
uint items; ///< The number of items stored
|
uint items; ///< The number of items stored
|
||||||
uint capacity; ///< The avalible space for storing items
|
uint capacity; ///< The avalible space for storing items
|
||||||
|
|
||||||
|
public:
|
||||||
SmallVector() : data(NULL), items(0), capacity(0) { }
|
SmallVector() : data(NULL), items(0), capacity(0) { }
|
||||||
|
|
||||||
~SmallVector()
|
~SmallVector()
|
||||||
|
@ -160,4 +162,4 @@ struct SmallVector {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SMALLVEC_H */
|
#endif /* SMALLVEC_TYPE_HPP */
|
|
@ -6,7 +6,7 @@
|
||||||
#define FIOS_H
|
#define FIOS_H
|
||||||
|
|
||||||
#include "strings_type.h"
|
#include "strings_type.h"
|
||||||
#include "misc/smallvec.h"
|
#include "core/smallvec_type.hpp"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "core/bitmath_func.hpp"
|
#include "core/bitmath_func.hpp"
|
||||||
#include "core/mem_func.hpp"
|
#include "core/mem_func.hpp"
|
||||||
#include "core/sort_func.hpp"
|
#include "core/sort_func.hpp"
|
||||||
#include "misc/smallvec.h"
|
#include "core/smallvec_type.hpp"
|
||||||
#include "date_type.h"
|
#include "date_type.h"
|
||||||
|
|
||||||
enum SortListFlags {
|
enum SortListFlags {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#ifndef VEHICLELIST_H
|
#ifndef VEHICLELIST_H
|
||||||
#define VEHICLELIST_H
|
#define VEHICLELIST_H
|
||||||
|
|
||||||
#include "misc/smallvec.h"
|
#include "core/smallvec_type.hpp"
|
||||||
|
|
||||||
typedef SmallVector<const Vehicle *, 32> VehicleList;
|
typedef SmallVector<const Vehicle *, 32> VehicleList;
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
#include "settings_type.h"
|
#include "settings_type.h"
|
||||||
#include "station_func.h"
|
#include "station_func.h"
|
||||||
#include "core/alloc_type.hpp"
|
#include "core/alloc_type.hpp"
|
||||||
#include "misc/smallvec.h"
|
#include "core/smallvec_type.hpp"
|
||||||
#include "window_func.h"
|
#include "window_func.h"
|
||||||
#include "tilehighlight_func.h"
|
#include "tilehighlight_func.h"
|
||||||
#include "window_gui.h"
|
#include "window_gui.h"
|
||||||
|
|
Loading…
Reference in New Issue