"updateLinesThreshold"

Defines how many lines minimum there have to be in order to use the new algorithm for the "updateLines" function.

Synopsis

int table.updateLinesThreshold(int value);

Parameters

Parameter Description
value Number of lines that indicate if the old or new algorithm will be used.

Description

If the updateLinesThreshold, for example, has been set to 5, Table.updateLinesThreshold = 5 and if the updateLines is called afterwards only with 3 lines, the old algorithm will be used. If the updateLines is called again with more than 5 lines, the new algorithm will be used. The difference between the old and the new algorithm is that the new one is faster when you need to update many lines.

The following example shows you how to set the updateLinesThreshold attribute and how to call the updateLines function afterwards to use the new faster update algorithm. In the example, new lines are also added to a table with the appendLine function. The updateLines function checks if there are persons named "Carl", "Julia" and "Mart" (these names are the key values for the updateLines function) in the table. If they do not exist in the table, the names are inserted into the table with their addresses (addresses are the new values of the updateLines function). The updateLinesThreshold is set to 2 and the updateLines function is called with 3 lines (Carl, Julia, Mart). Since the updateLinesThreshold is smaller than the amount of lines updated by the updateLines function, the new faster update algorithm will be used. Remember, that you see the difference between these two algorithms properly only when there is a larger number of lines.

main()
{
  int num = 1; /* key amount for the updateLines function */
  string name = "name"; /* name of a table column */
  string last_name = "last_name"; /*name of a table column */
  string address = "address"; /* name of a table column */
  dyn_dyn_string value1,new_value1; /*the variable declaration of the key value and of the new value for the updateLines function */
  
  DebugN("Appending lines"); 
  
  /* append lines to the table */
  Table1.appendLine("name", "Peter");
  Table1.appendLine("last_name", "Schimek");
  Table1.appendLine("name", "Maria");
  Table1.appendLine("last_name", "Meyer");
  Table1.appendLine("last_name", "Davis");
  Table1.appendLine("name", "Matt");
  
  /* Key values for the updateLines function. The function searches for these values in the table */
  value1[1]= makeDynString("Carl"); 
  value1[2]= makeDynString("Julia");
  value1[3]= makeDynString("Mart");
  
  /* these values are inserted into the table. Also the color of the column is changed */
  new_value1[1] = makeDynString("Puchberg 1"); 
  new_value1[2] = makeDynString("Mainstreet 45","[100, 40, 40]", "Red");
  new_value1[3] = makeDynString("Kleinerweg 9","[100, 40, 40]", "Red");
  
  /* the limit value (defines whether the old or the new algorithm is used)*/
  Table1.updateLinesThreshold = 2; 
  
  DebugN("Updating lines");
  
  /*the updateLines function searches for the defined names (key values) in the table and if 
  these don`t exist the names and the addresses (new values)are added into the table*/
  Table1.updateLines(num,name,value1,address,new_value1); 
}

Assignment

Table