-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
a57dc61
commit c21f97d
Showing
41 changed files
with
1,918 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> | ||
</startup> | ||
</configuration> |
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,74 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Laba2 | ||
{ | ||
class ClassArray<T> where T : ITransport | ||
{ | ||
|
||
private Dictionary<int, T> places; | ||
private int maxCount; | ||
//private T[] places; | ||
private T defaultValue; | ||
|
||
|
||
public ClassArray(int sizes,T defVal) | ||
{ | ||
defaultValue = defVal; | ||
places = new Dictionary<int, T>(); | ||
maxCount = sizes; | ||
|
||
} | ||
|
||
|
||
public static int operator +(ClassArray<T> p,T car) | ||
{ | ||
if(p.places.Count==p.maxCount) | ||
{ | ||
return -1; | ||
} | ||
for (int i=0;i<p.places.Count;i++) | ||
{ | ||
if (p.CheckFreePlace(i)) | ||
{ | ||
p.places.Add(i,car); | ||
return i; | ||
} | ||
} | ||
p.places.Add(p.places.Count, car); | ||
return p.places.Count - 1; | ||
|
||
} | ||
public static T operator -(ClassArray<T> p,int index) | ||
{ | ||
if (p.places.ContainsKey(index)) | ||
{ | ||
T car = p.places[index]; | ||
p.places.Remove(index); | ||
return car; | ||
} | ||
return p.defaultValue; | ||
} | ||
private bool CheckFreePlace(int index) | ||
{ | ||
|
||
return !places.ContainsKey(index); | ||
} | ||
public T this[int ind] | ||
{ | ||
get{ | ||
if (places.ContainsKey(ind)) | ||
{ | ||
return places[ind]; | ||
} | ||
return defaultValue; | ||
} | ||
} | ||
|
||
|
||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.