This commit is contained in:
Михаил Капелько
2024-03-25 23:26:56 +03:00
parent 3e231475b0
commit 1d5d88e315
7 changed files with 28 additions and 25 deletions

View File

@@ -2,4 +2,4 @@ c++ -o test_memory_C++ \
-Ilanguage-C++/Memory/src \
language-C++/Memory/src/Memory.Aux.cpp \
language-C++/Memory/src/Memory.Test.cpp \
language-C++/src/test.cpp
language-C++/src/main.cpp

View File

@@ -1,2 +1,4 @@
swiftc -o test_memory_Swift \
language-Swift/src/test.swift
language-Swift/Memory/src/Memory.Aux.swift \
language-Swift/Memory/src/Memory.Test.swift \
language-Swift/src/main.swift

View File

@@ -1,22 +1,14 @@
#include <map>
#include "Memory.h"
std::map<int, int> memory_generateConstPlayfield(
int n
) {
std::map<int, int> idGroups;
int id = 0;
for (int gid = 0; gid < n; ++gid) {
idGroups[id++] = gid;
idGroups[id++] = gid;
}
return idGroups;
}
func memory_generateConstPlayfield(
n: Int
_ n: Int
) -> [Int: Int] {
var idGroups = [Int: Int]()
var id = 0
for gid in stride(from: 0, to: n, by: 1) {
idGroups[id] = gid
id += 1
idGroups[id] = gid
id += 1
}
return idGroups
}

View File

@@ -0,0 +1,14 @@
func test_memory_generateConstPlayfield() -> String {
let idGroups = memory_generateConstPlayfield(2)
if (
idGroups.count == 4 &&
idGroups[0] == 0 &&
idGroups[1] == 0 &&
idGroups[2] == 1 &&
idGroups[3] == 1
) {
return "OK: memory_generateConstPlayfield"
}
return "ERR: memory_generateConstPlayfield";
}

View File

@@ -0,0 +1 @@
print(test_memory_generateConstPlayfield())

View File

@@ -1,6 +0,0 @@
print("Hello, world from Swift")
/*
std::cout
<< test_memory_generateConstPlayfield()
<< std::endl;
*/