2 using System
.Collections
.Generic
;
4 public class MyDict
<S
,T
> {
5 public void Add (S key
, T
value) {
14 public abstract class FastFunc
<S
,T
> {
15 public abstract S
Invoke (T bla
);
18 public class StringFastFunc
: FastFunc
<string, int> {
19 public override string Invoke (int bla
) {
20 return bla
.ToString ();
24 public class ArrayFastFunc
: FastFunc
<byte [], int> {
25 public override byte [] Invoke (int bla
) {
26 return new byte [bla
];
30 public class IntCache
<T
> {
33 public T
Invoke (FastFunc
<T
,int> f
, int bla
) {
35 cache
= new MyDict
<int,T
> ();
37 T
value = f
.Invoke (bla
);
39 cache
.Add (bla
, value);
46 public static int Main () {
47 StringFastFunc sff
= new StringFastFunc ();
48 ArrayFastFunc aff
= new ArrayFastFunc ();
49 IntCache
<string> ics
= new IntCache
<string> ();
50 MyDict
<string,string> dss
= new MyDict
<string,string> ();
52 dss
.Add ("123", "456");
54 ics
.Invoke (sff
, 123);
55 ics
.Invoke (sff
, 456);
57 IntCache
<byte []> ica
= new IntCache
<byte []> ();