CObArray SetSize()
Brian C. Wadell -- bcwadell@guidedwave.com Tuesday, May 21, 1996 Win 3.1, MFC 1.52c I am using a CObArray to store CTests which are a bunch of strings. I do a CTest *firstOne = new CTest; then fill in the strings and then Add to a CObArray derived CTestArray. Originally I wanted to use CArray but this isn't in 1.52. CObArray seems to be close so I am using it instead by wrapping it with my own class. GetSize() seems to go away for a long time. And most puzzling, Add() doesn't seem to change the value returned by GetSize(). Originally I didn't call SetSize() because I am adding five objects during and intialization and the potential overhead seemed likely to be small. I tried the function SetSize(initialSize, growBy) before I do any Adds and now it appears to be adding the first object at the initialSize location (observing the value of the document members using Locals). The next Add() grows the CTestArray/CObArray by growBy which makes sense. Why is it adding at the initialSize location? Shouldn't it add until initialSize objects are in the array and then enlarge by growBy and keep adding until intialSize + growBy and then enlarge by growBy again? Why is it slow? Any ideas are welcome. Thank you. Brian C. Wadell Guided Wave Solutions Hardware & Software Consulting test, high frequency, transmission lines, simulation E-mail: bcwadell@guidedwave.com WWW: http://www.tiac.net/users/bcwadell Voice/Fax: (617)-942-WAVE
Brian C. Wadell -- bcwadell@guidedwave.com Tuesday, May 28, 1996 I found the problem. When I inherited a new class I made the array a member. I was not referring to the member when I accessed the array so essentially I had a wild pointer which made the CObArray functions appear slow. The pointers all looked good when I was debugging but that was because I was looking at the right pointer and not the (wrong) one I was using! Brian C. Wadell Guided Wave Solutions Hardware & Software Consulting test, high frequency, transmission lines, simulation E-mail: bcwadell@guidedwave.com WWW: http://www.tiac.net/users/bcwadell Voice/Fax: (617)-942-WAVE
| Вернуться в корень Архива |