-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
70 changed files
with
505 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "Versioned.hpp" | ||
|
||
Versioned::Versioned() { } | ||
Versioned::Versioned(std::unordered_map<int, UnitAction> inner) : inner(inner) { } | ||
Versioned Versioned::readFrom(InputStream& stream) { | ||
Versioned result; | ||
size_t innerSize = stream.readInt(); | ||
result.inner = std::unordered_map<int, UnitAction>(); | ||
result.inner.reserve(innerSize); | ||
for (size_t i = 0; i < innerSize; i++) { | ||
int innerKey; | ||
innerKey = stream.readInt(); | ||
UnitAction innerValue; | ||
innerValue = UnitAction::readFrom(stream); | ||
result.inner.emplace(std::make_pair(innerKey, innerValue)); | ||
} | ||
return result; | ||
} | ||
void Versioned::writeTo(OutputStream& stream) const { | ||
stream.write(43981); | ||
stream.write((int)(inner.size())); | ||
for (const auto& innerEntry : inner) { | ||
stream.write(innerEntry.first); | ||
innerEntry.second.writeTo(stream); | ||
} | ||
} | ||
std::string Versioned::toString() const { | ||
return std::string("Versioned") + "(" + | ||
"TODO" + | ||
")"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef _MODEL_VERSIONED_HPP_ | ||
#define _MODEL_VERSIONED_HPP_ | ||
|
||
#include "../Stream.hpp" | ||
#include <string> | ||
#include <unordered_map> | ||
#include <stdexcept> | ||
#include "UnitAction.hpp" | ||
#include <stdexcept> | ||
#include "Vec2Double.hpp" | ||
|
||
class Versioned { | ||
public: | ||
std::unordered_map<int, UnitAction> inner; | ||
Versioned(); | ||
Versioned(std::unordered_map<int, UnitAction> inner); | ||
static Versioned readFrom(InputStream& stream); | ||
void writeTo(OutputStream& stream) const; | ||
std::string toString() const; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
namespace AiCup2019.Model | ||
{ | ||
public struct Versioned | ||
{ | ||
public System.Collections.Generic.IDictionary<int, Model.UnitAction> Inner { get; set; } | ||
public Versioned(System.Collections.Generic.IDictionary<int, Model.UnitAction> inner) | ||
{ | ||
this.Inner = inner; | ||
} | ||
public static Versioned ReadFrom(System.IO.BinaryReader reader) | ||
{ | ||
var result = new Versioned(); | ||
int InnerSize = reader.ReadInt32(); | ||
result.Inner = new System.Collections.Generic.Dictionary<int, Model.UnitAction>(InnerSize); | ||
for (int i = 0; i < InnerSize; i++) | ||
{ | ||
int InnerKey; | ||
InnerKey = reader.ReadInt32(); | ||
Model.UnitAction InnerValue; | ||
InnerValue = Model.UnitAction.ReadFrom(reader); | ||
result.Inner.Add(InnerKey, InnerValue); | ||
} | ||
return result; | ||
} | ||
public void WriteTo(System.IO.BinaryWriter writer) | ||
{ | ||
writer.Write(43981); | ||
writer.Write(Inner.Count); | ||
foreach (var InnerEntry in Inner) | ||
{ | ||
var InnerKey = InnerEntry.Key; | ||
var InnerValue = InnerEntry.Value; | ||
writer.Write(InnerKey); | ||
InnerValue.WriteTo(writer); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.