Click here to Skip to main content
15,907,497 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: Mimic Acrobat Reader behavior for a new file type Pin
Michael Dunn29-Jan-04 16:49
sitebuilderMichael Dunn29-Jan-04 16:49 
GeneralRe: Mimic Acrobat Reader behavior for a new file type Pin
pnyr30-Jan-04 11:53
pnyr30-Jan-04 11:53 
Questioncould the image and text be putted into a listview? Pin
freehawk28-Jan-04 22:08
freehawk28-Jan-04 22:08 
AnswerRe: could the image and text be putted into a listview? Pin
valikac29-Jan-04 6:28
valikac29-Jan-04 6:28 
GeneralRe: could the image and text be putted into a listview? Pin
freehawk29-Jan-04 13:51
freehawk29-Jan-04 13:51 
QuestionCould you give me any advice? Pin
freehawk28-Jan-04 17:54
freehawk28-Jan-04 17:54 
GeneralSTL valarray and slices Pin
Miszou28-Jan-04 11:53
Miszou28-Jan-04 11:53 
GeneralRe: STL valarray and slices Pin
Stuart Dootson28-Jan-04 22:26
professionalStuart Dootson28-Jan-04 22:26 
I think that you'll find that strides are more applicable to multi-dimensional arrays - for a contiguous slice of a 1-D array, the stride will be 1.

I would suggest that if you want 1-D arrays only and you're manipulating contiguous sub-sets of the array, then use vector. valarray has been generally recognised as not the best solution for the problem it was designed to solve (see this[^] and this[^]).

<edit>

And here's an example of valarray:

#include <valarray>
#include <iostream>
#include <iterator>

int main(int, char**)
{
   std::valarray<int> v(10);
   
   for(int i=0;i<v.size();++i)
      v[i] = i;
      
   std::valarray<int> v2(10);
   for(i=0;i<v2.size();++i)
      v2[i] = 200;
      
   for(i=0;i<v.size();++i)
      std::cout << ((i==0)?"":", ") << v[i];
   std::cout << "\n";

   std::slice_array<int> s = v[std::slice(1, 3, 2)];

   s += v2;

   for(i=0;i<v.size();++i)
      std::cout << ((i==0)?"":", ") << v[i];
   std::cout << "\n";
   
   return 1;
} 


gives this output

0, 1, 2, 3, 4, 5, 6, 7, 8, 9
0, 201, 2, 203, 4, 205, 6, 7, 8, 9


std::slice(1, 3, 2) defines a subset of a valarray containing 3 elements, starting at element 1 of the valarray, with each element of the slice separated by one valarray element (i.e. the slice references elements 1, 3 and 5 of the valarray).

But I'd still use a vector - valarray doesn't have iterators and isn't a proper STL container.

</edit>

Stuart Dootson

'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
GeneralRe: STL valarray and slices Pin
Miszou29-Jan-04 10:16
Miszou29-Jan-04 10:16 
Question.OCX or .DLL ? Pin
Dracula500028-Jan-04 8:20
Dracula500028-Jan-04 8:20 
AnswerRe: .OCX or .DLL ? Pin
Michael Dunn28-Jan-04 16:22
sitebuilderMichael Dunn28-Jan-04 16:22 
GeneralRe: .OCX or .DLL ? Pin
Dracula500029-Jan-04 8:36
Dracula500029-Jan-04 8:36 
GeneralUsing WTL controls in an MFC app Pin
armentage28-Jan-04 7:44
armentage28-Jan-04 7:44 
GeneralRe: Using WTL controls in an MFC app Pin
armentage28-Jan-04 7:56
armentage28-Jan-04 7:56 
GeneralRe: Using WTL controls in an MFC app Pin
Jörgen Sigvardsson28-Jan-04 7:59
Jörgen Sigvardsson28-Jan-04 7:59 
GeneralRe: Using WTL controls in an MFC app Pin
Jörgen Sigvardsson28-Jan-04 7:56
Jörgen Sigvardsson28-Jan-04 7:56 
GeneralRe: Using WTL controls in an MFC app Pin
armentage28-Jan-04 7:59
armentage28-Jan-04 7:59 
GeneralPlease help Pin
SiddharthAtw27-Jan-04 21:38
SiddharthAtw27-Jan-04 21:38 
QuestionHow to read file line by line? Pin
freehawk27-Jan-04 15:09
freehawk27-Jan-04 15:09 
AnswerRe: How to read file line by line? Pin
Christian Graus27-Jan-04 15:30
protectorChristian Graus27-Jan-04 15:30 
GeneralRe: How to read file line by line? Pin
freehawk27-Jan-04 23:40
freehawk27-Jan-04 23:40 
GeneralRe: How to read file line by line? Pin
Christian Graus28-Jan-04 9:00
protectorChristian Graus28-Jan-04 9:00 
AnswerRe: How to read file line by line? Pin
valikac28-Jan-04 8:01
valikac28-Jan-04 8:01 
GeneralRe: How to read file line by line? Pin
freehawk29-Jan-04 15:13
freehawk29-Jan-04 15:13 
QuestionHow to do like clicking the button of toolbar? Pin
freehawk27-Jan-04 15:08
freehawk27-Jan-04 15:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.