Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
Search the Tips

Arrays - Page 4

61-80 of 97     Previous     Next
Building arrays on the fly
by Francesco Balena
VB.NET supports the creation of arrays on-the-fly, by using the New operator. For example, look at the following code, that uses GDI methods to display few connected lines ' Get the Graphics object from the form. Dim gr As Graphics = Me.CreateGraphics ' Draw three straight lines. Dim ...
Speed up searches with hash tables
by Francesco Balena
You probably know that there are basically two methods to search a value in an array: the brute force approach (i.e. linear searching) and the binary search. Both of them have disadvantages: when the array counts N items, linear searching requires N/2 comparisons on the average for successful ...
Count Sort, a special case of indexed sort
by Francesco Balena
CountSort is yet another sort algorithm, which can be applied only under very particular conditions but that, when such conditions are met, turns to be the fastest of the lot. Count Sort can be used when the key is of Integer type, or when it is of Long type but the range of values is not too large.
Sorting on multiple keys
by Francesco Balena
Frequently you need to sort arrays of records using multiple keys. This may be required since one single key does not uniquely identify a record (e.g. you may need both LastName and FirstName to select a given employee in a large company where people with same name work), or it may be necessary ...
CBitArray - a class for dealing with large arrays of Boolean
by Francesco Balena
------------------------------------------------------------------------ The CBITARRAY class simiulates an array of Boolean values saves memory by packing one element in one bit IMPORTANT: you make make ITEM the default member for this class do this from inside the Tools | Procedure ...
RLECompress - Compress a block of memory using RLE algorithm
by Francesco Balena
compress a block of memory (a string, an array, a bitmap) using the RLE compression algorithm Returns True if the block has been compressed, False if the compression would create a block larger then the original data ADDRESS is the start address of the memory block to compress use ...
ArrayMax - The value and index of highest element in an array of any type
by Marco Bellinaso
Return the maximum value in an array of any type FIRST and LAST indicate which portion of the array should be considered; they default to the first and last element, respectively If MAXINDEX is passed, it receives the index of the maximum element in the array
ArrayMin - The value and index of lowest element in an array of any type
by Marco Bellinaso
Return the minimum value in an array of any type FIRST and LAST indicate which portion of the array should be considered; they default to the first and last element, respectively If MININDEX is passed, it receives the index of the minimum element in the array
ArrLongestItem - The value and index of the longest element of an array of any type
by Marco Bellinaso
The longest item in an array of any type (it applies the LEN function to all the items in the array and then takes the highest value) FIRST and LAST indicate which portion of the array should be considered; they default to the first and last element, respectively if LONGESTINDEX is ...
ArrShortestItem - The value and index of the shortest element of an array of any type
by Marco Bellinaso
The shortest item in an array of any type (it applies the LEN function to all the items in the array and then takes the highest value) FIRST and LAST indicate which portion of the array should be considered; they default to the first and last element, respectively if SHORTESTINDEX is ...
ListBoxEnsureVisible - Ensure that a ListBox element is visible
by Paul Wolff
ensure that a listbox item is visible if the second argument is omitted, the index of current item is used NOTE: uses the ListBoxVisibleItems function
TransposeMatrix - Rotate a bi-dimensional array
by Francesco Balena
evaluate the transposed matrix a transposed matrix is the array you get when you "rotate" a bi-dimensional array
CombSort - A very efficient algorithm
by Paul Wolff
Comb Sort an array of any type CombSort is faster than all but QuickSort and close to it. On the other hand, the code is much simpler than QuickSort and can be easily customized for any array type This routine is based on an article appeared on the Byte magazine in about 1985. NUMELS is ...
GetArrayInfo - Retreive number of dimensions and the SAFEARRAY memory structure
by Monte Hansen
Fills a SAFEARRAY structure for the supplied array. The information contained in the SAFEARRAY structure allows the caller to identify the number of dimensions and the number of elements for each dimension (among other things). Element information for each dimension is stored in a
ArrayAny - Return an initialized array of any type
by Francesco Balena
Returns an array and initializes it with passed data. It is similar to the Array function, but it works with array of any type. The type of the returned array is assumed to be the type of the first element in the parameter list, so you might need to force a given data type using one of the ...
Scan all the items in a multi-dimensional array with only one loop
by Francesco Balena
It seems that you need two nested For loops to iterate over all the elements of a 2-dimensional array, and three loops for a 3-dimensional array, and so on. However, the For Each loop offers you a neat and concise solution, as this code proves: ' a 2-dimensional array of Strings Dim ...
Simple variables are always faster than array elements
by Francesco Balena
Reading and writing an item of an array is always slower than accessing a simple variable. Therefore, if you need to repeatedly use the same array item in a loop, you should assign it to a temporary variable and use that variable instead. I've included an example of this technique that scans an ...
Filter - A replacement for VB6's Filter function under VB5
by Francesco Balena
A replace for the Filter function under VB4 and VB5 Note that the source array is modified. For this reason this is declared as a Sub rather than a Function
Undocumented trick to speed up functions that return array
by Francesco Balena
VB6 functions can return an array. Unlike regular functions that return scalar values or objects, however, you can't use the name of the function as a local variable where to store intermediate result, and you are forced to work with a temporary local array, and then assign this array to the ...
FilterDuplicates - Delete duplicate items in an array
by Francesco Balena
Filter out duplicate values in an array and compact the array by moving items to "fill the gaps". Returns the number of duplicate values it works with arrays of any type, except objects The array is not REDIMed, but you can do it easily using the following code: a() is a string array
61-80 of 97     Previous     Next
Sitemap