void
CBSymbolTable::Receive
	(
	JBroadcaster*	sender,
	const Message&	message
	)
{
	if (sender == itsSymbolList && message.Is(CBSymbolList::kChanged))
		{
		RebuildTable();
		}

	else if (sender == CBGetSymbolTypeList() &&
			 message.Is(CBSymbolTypeList::kVisibilityChanged))
		{
		RebuildTable();
		}
	else if (sender == CBGetSymbolTypeList() &&
			 message.Is(CBSymbolTypeList::kStyleChanged))
		{
		Refresh();
		}

	else
		{
		JXTable::Receive(sender, message);
		}
}
Example #2
0
BOOL MapParamDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

	m_frame = (CMainFrame *)AfxGetMainWnd();

	m_table_list.SetListFont(GetFont());
	m_table_list.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
	m_table_list.m_show_selection = false;
	RECT r;
	m_table_list.GetClientRect(&r);
	int len_N = 25, len_other = (r.right - r.left) - len_N - WIDTH_DATA_COL - 16;
	m_table_list.InsertColumn(0, "N", LVCFMT_LEFT, len_N);
    m_table_list.InsertColumn(1, "Параметр", LVCFMT_LEFT, len_other);
	m_table_list.InsertColumn(3, "Исходные данные", LVCFMT_LEFT, WIDTH_DATA_COL);
	RebuildTable();

	m_prev_selection = m_table_list.GetCurItem();

	m_table_list.m_lb_click_msg = WM_LIST_SELECTION_CHANGED;
	m_table_list.m_key_down_msg = WM_LIST_SELECTION_CHANGED;
	m_table_list.m_messages_wnd = this;

	return TRUE;
}
Example #3
0
void MapParamDlg::OnButtonDelete() 
{
	int mark = m_table_list.GetCurItem();
	DWORD param_num = m_table_list.GetItemData(mark);
	if (param_num <= MAX_PARAM)
	{
		MessageBox("Нельзя удалять зарезервированные параметры", "Параметр не будет удален");
		return;
	}
	if (MessageBox("Вы действительно хотите удалить параметр?", "Удалить параметр?", MB_YESNO) == IDYES)
	{
		{
			MutexWrap params_access(m_params_map_mutex); 
			CParam* param_to_delete;
			if (!m_MapParamDefault.Lookup(param_num, param_to_delete))
				return;
			pApp->SendMessageToActiveView(PM_DELETE_EXT_PARAM, param_num, 0);
			m_MapParamDefault.RemoveKey(param_num);
			m_MapParam.RemoveKey(param_num);
			delete param_to_delete;
			m_table_list.SetCurItem(mark - 1);
			m_prev_selection = m_table_list.GetCurItem();
		}
		RebuildTable();
	}
}
Example #4
0
static HashEntry *
ArrayCreate(HashTable *tablePtr, const void *key, int *newPtr) {
#if 0
  HashTable *tablePtr;	/* Table in which to lookup entry. */
  const void *key;		/* Key to use to find or create matching
				 * entry. */
  int *newPtr;		/* Store info here telling whether a new
				 * entry was created. */
#endif
  HashEntry *hPtr = NULL;
  unsigned int idx = HashArray(tablePtr, key);

  idx = RANDOM_INDEX(tablePtr, idx);

  /*
   * Search all of the entries in the appropriate bucket.
   */

  for (hPtr = tablePtr->buckets[idx];
       hPtr != NULL;
       hPtr = hPtr->nextPtr) {
    if (memcmp(key, (void *)hPtr->key.bytes, tablePtr->keyLen) == 0) {
      *newPtr = 0;
      return hPtr;
    }
  }

  /*
   * Entry not found.  Add a new one to the bucket.
   */
  hPtr = (HashEntry *)malloc(sizeof(HashEntry) - sizeof(hPtr->key) +
                             tablePtr->keyLen);
  if (hPtr != NULL) {
    *newPtr = 1;
    hPtr->tablePtr = tablePtr;
    hPtr->bucketPtr = &(tablePtr->buckets[idx]);
    hPtr->nextPtr = *hPtr->bucketPtr;
    hPtr->clientData = 0;
    (void)memcpy((void *)hPtr->key.bytes, key, tablePtr->keyLen);
    *hPtr->bucketPtr = hPtr;
    tablePtr->numEntries++;

    /*
     * If the table has exceeded a decent size, rebuild it with many
     * more buckets.
     */

    if (tablePtr->numEntries >= tablePtr->rebuildSize) {
      RebuildTable(tablePtr);
    }
  } else {
    *newPtr = 0;
  }

  return hPtr;
}
Example #5
0
static HashEntry *
OneWordCreate(HashTable *tablePtr, const void *key, int *newPtr) {
#if 0
  HashTable *tablePtr;	/* Table in which to lookup entry. */
  const void *key;		/* Key to use to find or create matching
				 * entry. */
  int *newPtr;		/* Store info here telling whether a new
				 * entry was created. */
#endif
  HashEntry *hPtr;
  unsigned int idx;

  idx = RANDOM_INDEX(tablePtr, key);

  /*
   * Search all of the entries in this bucket.
   */

  for (hPtr = tablePtr->buckets[idx];
       hPtr != NULL;
       hPtr = hPtr->nextPtr) {
    if (hPtr->key.oneWordKey == key) {
      *newPtr = 0;
      return hPtr;
    }
  }

  /*
   * Entry not found.  Add a new one to the bucket.
   */

  hPtr = (HashEntry *)malloc(sizeof(HashEntry));
  if (hPtr != NULL) {
    *newPtr = 1;
    hPtr->tablePtr = tablePtr;
    hPtr->bucketPtr = &(tablePtr->buckets[idx]);
    hPtr->nextPtr = *hPtr->bucketPtr;
    hPtr->clientData = 0;
    hPtr->key.oneWordKey = key;
    *hPtr->bucketPtr = hPtr;
    tablePtr->numEntries++;

    /*
     * If the table has exceeded a decent size, rebuild it with
     * many more buckets.
     */

    if (tablePtr->numEntries >= tablePtr->rebuildSize) {
      RebuildTable(tablePtr);
    }
  } else {
    *newPtr = 0;
  }
  return hPtr;
}
void
CBSymbolTable::SetDisplayList
	(
	const JArray<JIndex>& list
	)
{
	*itsVisibleList = list;
	itsVisibleList->SetBlockSize(CBSymbolList::kBlockSize);
	itsVisibleListLockedFlag = kJTrue;
	ScrollTo(0,0);
	RebuildTable();
}
Example #7
0
Hash_Entry *
Hash_CreateEntry(
	register Hash_Table *t,	/* Hash table to search. */
	char *key,		/* A hash key. */
	Boolean *newPtr)	/* Filled in with TRUE if new entry created,
				 * FALSE otherwise. */
{
	register Hash_Entry *e;
	register unsigned h;
	register char *p;
	int keylen;
	struct Hash_Entry **hp;

	/*
	 * Hash the key.  As a side effect, save the length (strlen) of the
	 * key in case we need to create the entry.
	 */
	for (h = 0, p = key; *p;)
		h = (h << 5) - h + *p++;
	keylen = p - key;
	p = key;
	for (e = t->bucketPtr[h & t->mask]; e != NULL; e = e->next) {
		if (e->namehash == h && strcmp(e->name, p) == 0) {
			if (newPtr != NULL)
				*newPtr = FALSE;
			return (e);
		}
	}

	/*
	 * The desired entry isn't there.  Before allocating a new entry,
	 * expand the table if necessary (and this changes the resulting
	 * bucket chain).
	 */
	if (t->numEntries >= rebuildLimit * t->size)
		RebuildTable(t);
	e = (Hash_Entry *) emalloc(sizeof(*e) + keylen);
	hp = &t->bucketPtr[h & t->mask];
	e->next = *hp;
	*hp = e;
	e->clientData = NULL;
	e->namehash = h;
	(void) strcpy(e->name, p);
	t->numEntries++;

	if (newPtr != NULL)
		*newPtr = TRUE;
	return (e);
}
void
CBSymbolTable::ShowAll()
{
	itsVisibleListLockedFlag = kJFalse;
	itsVisibleList->RemoveAll();	// force rebuild of entire list

	delete itsNameFilter;
	itsNameFilter = NULL;

	delete itsNameLiteral;
	itsNameLiteral = NULL;

	ScrollTo(0,0);
	RebuildTable();
}
Example #9
0
Hash_Entry *
Hash_CreateEntry(Hash_Table *t, const char *key, Boolean *newPtr)
{
	Hash_Entry *e;
	unsigned h;
	const char *p;
	int keylen;
	struct Hash_Entry **hp;

	/*
	 * Hash the key.  As a side effect, save the length (strlen) of the
	 * key in case we need to create the entry.
	 */
	for (h = 0, p = key; *p;)
		h = (h << 5) - h + *p++;
	keylen = p - key;
	p = key;
	for (e = t->bucketPtr[h & t->mask]; e != NULL; e = e->next) {
		if (e->namehash == h && strcmp(e->name, p) == 0) {
			if (newPtr != NULL)
				*newPtr = FALSE;
			return (e);
		}
	}

	/*
	 * The desired entry isn't there.  Before allocating a new entry,
	 * expand the table if necessary (and this changes the resulting
	 * bucket chain).
	 */
	if (t->numEntries >= rebuildLimit * t->size)
		RebuildTable(t);
	e = bmake_malloc(sizeof(*e) + keylen);
	hp = &t->bucketPtr[h & t->mask];
	e->next = *hp;
	*hp = e;
	Hash_SetValue(e, NULL);
	e->namehash = h;
	(void)strcpy(e->name, p);
	t->numEntries++;

	if (newPtr != NULL)
		*newPtr = TRUE;
	return (e);
}
Example #10
0
void MapParamDlg::OnButtonAdd() 
{
	CParam *param = new CParam(), *other;
	param->sName = "Новый параметр";
	param->m_channel_num = -1;

	for (param->m_num_par = MAX_PARAM + 1; param->m_num_par < 10000; param->m_num_par++)
		if (!m_MapParamDefault.Lookup(param->m_num_par, other))
			break;

	NewCorrespondenceDlg dlg(param, true);
	if (dlg.DoModal() == IDOK)
	{
		param->Init();
		m_MapParamDefault[param->m_num_par] = param; 
		if (param->bParamActive)
			m_MapParam[param->m_num_par] = param;
		RebuildTable();
	}
}
Example #11
0
hash_entry_t *
Hash_CreateEntry(hash_table_t *table, /* Hash table to search. */
                unsigned int hash,  /* A hash key. */
                int *newPtr /* Filled in with TRUE if new entry created,
                             * FALSE otherwise. */
                )                             
{
    hash_entry_t *e;
    for (e = table->bucketPtr[hash & table->mask]; e != NULL; e = e->next) {
        if (e->namehash == hash) {
            if (newPtr != NULL) {
                *newPtr = FALSE;
            }                
            break;
        }
    }
    if (!e) {
        /*
         * The desired entry isn'table there.  Before allocating a new entry,
         * expand the table if necessary (and this changes the resulting
         * bucket chain).
         */
        if ((table->numEntries < (rebuildLimit * table->size)) || RebuildTable(table)) 
        { 
            e = (hash_entry_t *) malloc(sizeof(hash_entry_t));/*emalloc(sizeof(*e) + keylen);*/
            if (e) {
                hash_entry_t **hp= &table->bucketPtr[hash & table->mask];
                e->next = *hp;              // point at whatever was in the bucket
                *hp = e;                    // put us in the bucket
                e->clientData = NULL;
                e->clientFlags= 0;
                e->namehash = hash;
                ++table->numEntries;
                if (newPtr != NULL) {
                    *newPtr = TRUE;
                }                
            }
        }        
    }        
    return (e);
}
JError
CBSymbolTable::SetNameFilter
	(
	const JCharacter*	filterStr,
	const JBoolean		isRegex
	)
{
	delete itsNameFilter;
	itsNameFilter = NULL;

	delete itsNameLiteral;
	itsNameLiteral = NULL;

	JError result = JNoError();
	if (isRegex)
		{
		itsNameFilter = new JRegex;
		assert( itsNameFilter != NULL );
		result = itsNameFilter->SetPattern(filterStr);
		if (!result.OK())
			{
			delete itsNameFilter;
			itsNameFilter = NULL;
			}
		}
	else
		{
		itsNameLiteral = new JString(filterStr);
		assert( itsNameLiteral != NULL );
		}

	itsVisibleListLockedFlag = kJFalse;

	ScrollTo(0,0);
	RebuildTable();
	return result;
}
Example #13
0
static HashEntry *
StringCreate(HashTable *tablePtr, const void *vKey, int *newPtr) {
#if 0
  HashTable *tablePtr;	/* Table in which to lookup entry. */
  const void *key;		/* Key to use to find or create matching
				 * entry. */
  int *newPtr;		/* Store info here telling whether a new
				 * entry was created. */
#endif
  const char *key = (const char *)vKey;
  HashEntry *hPtr = NULL;

  if (key != NULL) {
    unsigned int idx = HashString(key) & tablePtr->mask;
    size_t kLen = strlen(key);

    /*
     * Search all of the entries in this bucket.
     */

    for (hPtr = tablePtr->buckets[idx];
         hPtr != NULL;
         hPtr = hPtr->nextPtr) {
      if (strcmp(key, hPtr->key.string) == 0) {
        *newPtr = 0;
        return hPtr;
      }
    }

    /*
     * Entry not found.  Add a new one to the bucket.
     */
    hPtr = (HashEntry *)malloc(sizeof(HashEntry) - sizeof(hPtr->key) +
                               kLen + 1);
    if (hPtr != NULL) {
      *newPtr = 1;
      hPtr->tablePtr = tablePtr;
      hPtr->bucketPtr = &(tablePtr->buckets[idx]);
      hPtr->nextPtr = *hPtr->bucketPtr;
      hPtr->clientData = 0;
      (void)memcpy((void *)(hPtr->key.string), (void *)key, kLen + 1);
      *hPtr->bucketPtr = hPtr;
      tablePtr->numEntries++;

      /*
       * If the table has exceeded a decent size, rebuild it with many
       * more buckets.
       */

      if (tablePtr->numEntries >= tablePtr->rebuildSize) {
        RebuildTable(tablePtr);
      }
    } else {
      *newPtr = 0;
    }
  } else {
    *newPtr = 0;
  }

  return hPtr;
}
Example #14
0
Tcl_HashEntry *
Tcl_CreateHashEntry(
    Tcl_HashTable *tablePtr,	/* Table in which to lookup entry. */
    const char *key,		/* Key to use to find or create matching
				 * entry. */
    int *newPtr)		/* Store info here telling whether a new entry
				 * was created. */
{
    register Tcl_HashEntry *hPtr;
    const Tcl_HashKeyType *typePtr;
    unsigned int hash;
    int index;

    if (tablePtr->keyType == TCL_STRING_KEYS) {
	typePtr = &tclStringHashKeyType;
    } else if (tablePtr->keyType == TCL_ONE_WORD_KEYS) {
	typePtr = &tclOneWordHashKeyType;
    } else if (tablePtr->keyType == TCL_CUSTOM_TYPE_KEYS
	    || tablePtr->keyType == TCL_CUSTOM_PTR_KEYS) {
	typePtr = tablePtr->typePtr;
    } else {
	typePtr = &tclArrayHashKeyType;
    }

    if (typePtr->hashKeyProc) {
	hash = typePtr->hashKeyProc(tablePtr, (void *) key);
	if (typePtr->flags & TCL_HASH_KEY_RANDOMIZE_HASH) {
	    index = RANDOM_INDEX (tablePtr, hash);
	} else {
	    index = hash & tablePtr->mask;
	}
    } else {
	hash = PTR2UINT(key);
	index = RANDOM_INDEX (tablePtr, hash);
    }

    /*
     * Search all of the entries in the appropriate bucket.
     */

    if (typePtr->compareKeysProc) {
	Tcl_CompareHashKeysProc *compareKeysProc = typePtr->compareKeysProc;
	for (hPtr = tablePtr->buckets[index]; hPtr != NULL;
		hPtr = hPtr->nextPtr) {
#if TCL_HASH_KEY_STORE_HASH
	    if (hash != PTR2UINT(hPtr->hash)) {
		continue;
	    }
#endif
	    if (compareKeysProc((void *) key, hPtr)) {
		if (newPtr) {
		    *newPtr = 0;
		}
		return hPtr;
	    }
	}
    } else {
	for (hPtr = tablePtr->buckets[index]; hPtr != NULL;
		hPtr = hPtr->nextPtr) {
#if TCL_HASH_KEY_STORE_HASH
	    if (hash != PTR2UINT(hPtr->hash)) {
		continue;
	    }
#endif
	    if (key == hPtr->key.oneWordValue) {
		if (newPtr) {
		    *newPtr = 0;
		}
		return hPtr;
	    }
	}
    }

    if (!newPtr) {
	return NULL;
    }

    /*
     * Entry not found. Add a new one to the bucket.
     */

    *newPtr = 1;
    if (typePtr->allocEntryProc) {
	hPtr = typePtr->allocEntryProc(tablePtr, (void *) key);
    } else {
	hPtr = (Tcl_HashEntry *) ckalloc((unsigned) sizeof(Tcl_HashEntry));
	hPtr->key.oneWordValue = (char *) key;
	hPtr->clientData = 0;
    }

    hPtr->tablePtr = tablePtr;
#if TCL_HASH_KEY_STORE_HASH
    hPtr->hash = UINT2PTR(hash);
    hPtr->nextPtr = tablePtr->buckets[index];
    tablePtr->buckets[index] = hPtr;
#else
    hPtr->bucketPtr = &(tablePtr->buckets[index]);
    hPtr->nextPtr = *hPtr->bucketPtr;
    *hPtr->bucketPtr = hPtr;
#endif
    tablePtr->numEntries++;

    /*
     * If the table has exceeded a decent size, rebuild it with many more
     * buckets.
     */

    if (tablePtr->numEntries >= tablePtr->rebuildSize) {
	RebuildTable(tablePtr);
    }
    return hPtr;
}