Advertisement
Guest User

Untitled

a guest
Nov 12th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 1.05 KB | None | 0 0
  1. namespace Gee
  2. {
  3.     public struct PEntry<K ,V>
  4.     {
  5.         K Key;
  6.         V Value;
  7.         public PEntry(K key, V value)
  8.         {
  9.             Key = key;
  10.             Value = value;
  11.         }
  12.     }
  13.    
  14.     public class HashMapExtensions<K,V> : HashMap<K,V>
  15.     {
  16.         //stub, will it build?
  17.         public HashMapExtensions()
  18.         {
  19.             base();
  20.         }
  21.         public HashMapExtensions.from_data(PEntry<K,V>[] entries)
  22.         {
  23.             base();
  24.             foreach (PEntry<K,V> entry in entries)
  25.             {
  26.                 base.set(entry.Key, entry.Value);
  27.             }
  28.         }
  29.     }
  30. }
  31.  
  32.     public class Program
  33.     {
  34.         /*
  35.         public static Gee.HashMapExtensions<int, int> bla = new Gee.HashMapExtensions<int, int>.from_data({
  36.             {0, 0}
  37.         });
  38.         */
  39.         public static Gee.HashMapExtensions<int, string> bla = new Gee.HashMapExtensions<int, string>.from_data({
  40.             Gee.PEntry<int, string>(1 ,"HEY"),
  41.             Gee.PEntry<int, string>(3, "STE")
  42.         });
  43.  
  44.         public static int main(string[] args)
  45.         {
  46.                 stdout.printf("Value: %s\n", bla[1]);
  47.                 return 0;
  48.         }
  49.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement