MetaCollectionDb
Namespace:
Itinero
We found 6 examples in language CSharp for this search.
You will see 29 fragments of code.
Other methods
Other methods
Project:routing
File:MetaCollectionsDbTests.cs
Examples:2
/// <summary>
/// Tests creating a db.
/// </summary>
[Test]
public void TestCreate()
{
var db = new MetaCollectionDb();
MetaCollection<int> col;
Assert.IsFalse(db.TryGet<int>("not-there", out col));
}
/// <summary>
/// Tests add get collections.
/// </summary>
[Test]
public void TestAddGet()
{
var db = new MetaCollectionDb();
var intCol = db.AddInt32("int");
intCol[1023] = 1;
var dblCol = db.AddDouble("double");
dblCol[1023] = 1;
Assert.IsTrue(db.TryGet<int>("int", out intCol));
Assert.IsTrue(db.TryGet<double>("double", out dblCol));
}
Project:Licence-Thesis-UTCN
File:MetaCollectionsDbTests.cs
Examples:3
/// <summary>
/// Tests creating a db.
/// </summary>
[Test]
public void TestCreate()
{
var db = new MetaCollectionDb();
MetaCollection<int> col;
Assert.IsFalse(db.TryGet<int>("not-there", out col));
}
/// <summary>
/// Tests add get collections.
/// </summary>
[Test]
public void TestAddGet()
{
var db = new MetaCollectionDb();
var intCol = db.AddInt32("int");
intCol[1023] = 1;
var dblCol = db.AddDouble("double");
dblCol[1023] = 1;
Assert.IsTrue(db.TryGet<int>("int", out intCol));
Assert.IsTrue(db.TryGet<double>("double", out dblCol));
}
/// <summary>
/// Tests serialize/deserialize.
/// </summary>
[Test]
public void TestSerializeDeserialize()
{
var db = new MetaCollectionDb();
var intCol = db.AddInt32("int");
var dblCol = db.AddDouble("double");
var size = 15213;
for (uint i = 0; i < size; i++)
{
intCol[i] = (int)(i * 2);
}
for (uint i = 0; i < size; i++)
{
dblCol[i] = i * .1;
}
using (var stream = new MemoryStream())
{
db.Serialize(stream);
stream.Seek(0, SeekOrigin.Begin);
db = MetaCollectionDb.Deserialize(stream, null);
}
Assert.IsTrue(db.TryGet<int>("int", out intCol));
Assert.IsTrue(db.TryGet<double>("double", out dblCol));
for (uint i = 0; i < intCol.Count; i++)
{
Assert.AreEqual((int)i * 2, intCol[i]);
}
for (uint i = 0; i < dblCol.Count; i++)
{
Assert.AreEqual(i * .1, dblCol[i]);
}
}
Project:ProyectoTSP
File:MetaCollectionsDb.cs
Examples:6
/// <summary>
/// Removes all data.
/// </summary>
public void Clear()
{
_collections.Clear();
}
/// <summary>
/// Gets the type of the collection with the given name.
/// </summary>
public Type GetType(string name)
{
MetaCollection collection;
if (_collections.TryGetValue(name, out collection))
{
return collection.ElementType;
}
return null;
}
/// <summary>
/// Switches the two items around.
/// </summary>
public void Switch(uint item1, uint item2)
{
foreach(var collection in _collections)
{
collection.Value.Switch(item1, item2);
}
}
/// <summary>
/// Copies whatever data is in 'from' to 'to'.
/// </summary>
public void Copy(uint to, uint from)
{
foreach(var collection in _collections)
{
collection.Value.Copy(to, from);
}
}
/// <summary>
/// Sets the item to the default empty value.
/// </summary>
public void SetEmpty(uint item)
{
foreach(var collection in _collections)
{
collection.Value.SetEmpty(item);
}
}
/// <summary>
/// Adds a new meta collection.
/// </summary>
/// <param name="name"></param>
/// <param name="type"></param>
/// <returns></returns>
public MetaCollection Add(string name, Type type)
{
if (type == typeof(int))
{
return this.AddInt32(name);
}
if (type == typeof(uint))
{
return this.AddUInt32(name);
}
if (type == typeof(long))
{
return this.AddInt64(name);
}
if (type == typeof(ulong))
{
return this.AddUInt64(name);
}
if (type == typeof(float))
{
return this.AddSingle(name);
}
if (type == typeof(double))
{
return this.AddDouble(name);
}
if (type == typeof(short))
{
return this.AddInt16(name);
}
if (type == typeof(ushort))
{
return this.AddUInt16(name);
}
throw new Exception(string.Format(
"Meta collection not supported for type {0}: MetaCollection can only handle integer types or float and double.",
type));
}
Project:routing
File:MetaCollectionsDb.cs
Examples:6
/// <summary>
/// Removes all data.
/// </summary>
public void Clear()
{
_collections.Clear();
}
/// <summary>
/// Gets the type of the collection with the given name.
/// </summary>
public Type GetType(string name)
{
MetaCollection collection;
if (_collections.TryGetValue(name, out collection))
{
return collection.ElementType;
}
return null;
}
/// <summary>
/// Switches the two items around.
/// </summary>
public void Switch(uint item1, uint item2)
{
foreach(var collection in _collections)
{
collection.Value.Switch(item1, item2);
}
}
/// <summary>
/// Copies whatever data is in 'from' to 'to'.
/// </summary>
public void Copy(uint to, uint from)
{
foreach(var collection in _collections)
{
collection.Value.Copy(to, from);
}
}
/// <summary>
/// Sets the item to the default empty value.
/// </summary>
public void SetEmpty(uint item)
{
foreach(var collection in _collections)
{
collection.Value.SetEmpty(item);
}
}
/// <summary>
/// Adds a new meta collection.
/// </summary>
/// <param name="name"></param>
/// <param name="type"></param>
/// <returns></returns>
public MetaCollection Add(string name, Type type)
{
if (type == typeof(int))
{
return this.AddInt32(name);
}
if (type == typeof(uint))
{
return this.AddUInt32(name);
}
if (type == typeof(long))
{
return this.AddInt64(name);
}
if (type == typeof(ulong))
{
return this.AddUInt64(name);
}
if (type == typeof(float))
{
return this.AddSingle(name);
}
if (type == typeof(double))
{
return this.AddDouble(name);
}
if (type == typeof(short))
{
return this.AddInt16(name);
}
if (type == typeof(ushort))
{
return this.AddUInt16(name);
}
throw new Exception(string.Format(
"Meta collection not supported for type {0}: MetaCollection can only handle integer types or float and double.",
type));
}
Project:Licence-Thesis-UTCN
File:MetaCollectionsDb.cs
Examples:6
/// <summary>
/// Removes all data.
/// </summary>
public void Clear()
{
_collections.Clear();
}
/// <summary>
/// Gets the type of the collection with the given name.
/// </summary>
public Type GetType(string name)
{
MetaCollection collection;
if (_collections.TryGetValue(name, out collection))
{
return collection.ElementType;
}
return null;
}
/// <summary>
/// Switches the two items around.
/// </summary>
public void Switch(uint item1, uint item2)
{
foreach(var collection in _collections)
{
collection.Value.Switch(item1, item2);
}
}
/// <summary>
/// Copies whatever data is in 'from' to 'to'.
/// </summary>
public void Copy(uint to, uint from)
{
foreach(var collection in _collections)
{
collection.Value.Copy(to, from);
}
}
/// <summary>
/// Sets the item to the default empty value.
/// </summary>
public void SetEmpty(uint item)
{
foreach(var collection in _collections)
{
collection.Value.SetEmpty(item);
}
}
/// <summary>
/// Adds a new meta collection.
/// </summary>
/// <param name="name"></param>
/// <param name="type"></param>
/// <returns></returns>
public MetaCollection Add(string name, Type type)
{
if (type == typeof(int))
{
return this.AddInt32(name);
}
if (type == typeof(uint))
{
return this.AddUInt32(name);
}
if (type == typeof(long))
{
return this.AddInt64(name);
}
if (type == typeof(ulong))
{
return this.AddUInt64(name);
}
if (type == typeof(float))
{
return this.AddSingle(name);
}
if (type == typeof(double))
{
return this.AddDouble(name);
}
if (type == typeof(short))
{
return this.AddInt16(name);
}
if (type == typeof(ushort))
{
return this.AddUInt16(name);
}
throw new Exception(string.Format(
"Meta collection not supported for type {0}: MetaCollection can only handle integer types or float and double.",
type));
}
Project:Licence-Thesis-UTCN
File:MetaCollectionsDb.cs
Examples:6
/// <summary>
/// Removes all data.
/// </summary>
public void Clear()
{
_collections.Clear();
}
/// <summary>
/// Gets the type of the collection with the given name.
/// </summary>
public Type GetType(string name)
{
MetaCollection collection;
if (_collections.TryGetValue(name, out collection))
{
return collection.ElementType;
}
return null;
}
/// <summary>
/// Switches the two items around.
/// </summary>
public void Switch(uint item1, uint item2)
{
foreach(var collection in _collections)
{
collection.Value.Switch(item1, item2);
}
}
/// <summary>
/// Copies whatever data is in 'from' to 'to'.
/// </summary>
public void Copy(uint to, uint from)
{
foreach(var collection in _collections)
{
collection.Value.Copy(to, from);
}
}
/// <summary>
/// Sets the item to the default empty value.
/// </summary>
public void SetEmpty(uint item)
{
foreach(var collection in _collections)
{
collection.Value.SetEmpty(item);
}
}
/// <summary>
/// Adds a new meta collection.
/// </summary>
/// <param name="name"></param>
/// <param name="type"></param>
/// <returns></returns>
public MetaCollection Add(string name, Type type)
{
if (type == typeof(int))
{
return this.AddInt32(name);
}
if (type == typeof(uint))
{
return this.AddUInt32(name);
}
if (type == typeof(long))
{
return this.AddInt64(name);
}
if (type == typeof(ulong))
{
return this.AddUInt64(name);
}
if (type == typeof(float))
{
return this.AddSingle(name);
}
if (type == typeof(double))
{
return this.AddDouble(name);
}
if (type == typeof(short))
{
return this.AddInt16(name);
}
if (type == typeof(ushort))
{
return this.AddUInt16(name);
}
throw new Exception(string.Format(
"Meta collection not supported for type {0}: MetaCollection can only handle integer types or float and double.",
type));
}
Itinero.Data.Network.Edges.MetaCollectionDb : Object
Constructors :
public MetaCollectionDb()Methods :
public IEnumerable<String> get_Names()public Void Clear()
public Type GetType(String name = )
public Void Switch(UInt32 item1 = , UInt32 item2 = )
public Void Copy(UInt32 to = , UInt32 from = )
public Void SetEmpty(UInt32 item = )
public MetaCollection Add(String name = , Type type = )
public MetaCollection<Int32> AddInt32(String name = )
public MetaCollection<UInt32> AddUInt32(String name = )
public MetaCollection<Int64> AddInt64(String name = )
public MetaCollection<UInt64> AddUInt64(String name = )
public MetaCollection<Single> AddSingle(String name = )
public MetaCollection<Double> AddDouble(String name = )
public MetaCollection<Int16> AddInt16(String name = )
public MetaCollection<UInt16> AddUInt16(String name = )
public MetaCollection Get(String name = )
public Boolean TryGet(String name = , MetaCollection& metaCollection = )
public MetaCollection<T> Get(String name = )
public Boolean TryGet(String name = , MetaCollection metaCollection = )
public Int64 Serialize(Stream stream = )
public static MetaCollectionDb Deserialize(Stream stream = , ArrayProfile profile = null)
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()