// Remove an element from this handle map. public void Remove(XWindow window) { // Look in the main part of the table. int hash = (((int)window) & (HashSize - 1)); if (handles[hash].window == window) { handles[hash].window = XWindow.Zero; handles[hash].widget = null; return; } // Look in the overflow part of the table. HandleOverflowInfo info = handles[hash].overflow; while (info != null) { if (info.window == window) { info.window = XWindow.Zero; info.widget = null; return; } info = info.overflow; } }
// Get or set a member within this handle map. public Widget this[XWindow window] { get { // Look in the main part of the table. int hash = (((int)window) & (HashSize - 1)); if (handles[hash].window == window) { return(handles[hash].widget); } // Look in the overflow part of the table. HandleOverflowInfo info = handles[hash].overflow; while (info != null) { if (info.window == window) { return(info.widget); } info = info.overflow; } // There is no widget registered with this handle. return(null); } set { // Look in the main part of the table. int hash = (((int)window) & (HashSize - 1)); if (handles[hash].window == window) { handles[hash].widget = value; return; } // Look in the overflow part of the table. HandleOverflowInfo info = handles[hash].overflow; while (info != null) { if (info.window == window) { info.widget = value; return; } info = info.overflow; } // Add to the main part of the table if it is empty. if (handles[hash].window == XWindow.Zero) { handles[hash].window = window; handles[hash].widget = value; return; } // Add an overflow entry to the hash table. info = new HandleOverflowInfo(); info.window = window; info.widget = value; info.overflow = handles[hash].overflow; handles[hash].overflow = info; } }
// Get or set a member within this handle map. public Widget this[XWindow window] { get { // Look in the main part of the table. int hash = (((int)window) & (HashSize - 1)); if(handles[hash].window == window) { return handles[hash].widget; } // Look in the overflow part of the table. HandleOverflowInfo info = handles[hash].overflow; while(info != null) { if(info.window == window) { return info.widget; } info = info.overflow; } // There is no widget registered with this handle. return null; } set { // Look in the main part of the table. int hash = (((int)window) & (HashSize - 1)); if(handles[hash].window == window) { handles[hash].widget = value; return; } // Look in the overflow part of the table. HandleOverflowInfo info = handles[hash].overflow; while(info != null) { if(info.window == window) { info.widget = value; return; } info = info.overflow; } // Add to the main part of the table if it is empty. if(handles[hash].window == XWindow.Zero) { handles[hash].window = window; handles[hash].widget = value; return; } // Add an overflow entry to the hash table. info = new HandleOverflowInfo(); info.window = window; info.widget = value; info.overflow = handles[hash].overflow; handles[hash].overflow = info; } }