The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]

Интерактивная система просмотра системных руководств (man-ов)

 ТемаНаборКатегория 
 
 [Cписок руководств | Печать]

indirect_array (3)
  • >> indirect_array (3) ( Solaris man: Библиотечные вызовы )
  • 
                           Standard C++ Library
                 Copyright 1998, Rogue Wave Software, Inc.
    
    
    NAME
         indirect_array
    
          - A numeric array class used to represent elements selected
         from a valarray.
    
    
    
    SYNOPSIS
         #include <valarray>
         template <class T>
         class indirect_array ;
    
    
    
    DESCRIPTION
         indirect_array<T> creates a selective view into a  valarray.
         Indirect_arrays  are  produced by applying the indirect sub-
         script operator to a valarray. The indirect  array  produced
         by this subscript contains only the elements of the valarray
         whose indices appear as values in the argument. The elements
         in  an indirect_array are references to selected elements in
         the valarray (so changing an element in  the  indirect_array
         really  changes  the corresponding element in the valarray).
         An indirect_array does not itself  hold  any  distinct  ele-
         ments.  The  template  cannot be instantiated directly since
         all its constructors are private. However, you can  copy  an
         indirect_array  to a valarray using either the valarray copy
         constructor or the assignment operator. Reference  semantics
         are lost at that point.
    
    
    
    INTERFACE
         template <class T> class indirect_array {
         public:
    
           // types
          typedef T value_type;
    
           // destructor
           ~indirect_array();
    
           // public assignment
          void operator= (const valarray<T>& array) const;
           // computed assignment
          void operator*= (const valarray<T>& array) const;
          void operator/= (const valarray<T>& array) const;
          void operator%= (const valarray<T>& array) const;
          void operator+= (const valarray<T>& array) const;
          void operator-= (const valarray<T>& array) const;
          void operator^= (const valarray<T>& array) const;
          void operator&= (const valarray<T>& array) const;
          void operator|= (const valarray<T>& array) const;
          void operator<<= (const valarray<T>& array) const;
          void operator>>= (const valarray<T>& array) const;
    
           // fill function
          void operator=(const T&);
    
         private:
           // constructors
          indirect_array();
          indirect_array(const indirect_array<T>&);
           // operator =
          indirect_array<T>&
             operator= (const indirect_array<T>& array);
         };
    
    
    
    CONSTRUCTORS
         indirect_array();
         indirect_array(const indirect_array&);
    
    
            All indirect_array constructors are private and cannot be
            called  directly.  This  prevents  copy  construction  of
            indirect_arrays.
    
    
    
    ASSIGNMENT OPERATORS
         void operator=(const valarray<T>& x) const;
    
    
            Assigns values from x to the  selected  elements  of  the
            valarray   that   self   refers   to.  Remember  that  an
            indirect_array never holds any elements itself; it simply
            refers  to selected elements in the valarray used to gen-
            erate it.
    
    
    
         indirect_array<T>&
         operator=(const indirect-_array<T>& x);
    
    
            Private assignment operator. Cannot be  called  directly,
            thus preventing assignment between indirect_arrays.
    
    
    
    COMPUTED ASSIGNMENT OPERATORS
         void operator*=(const valarray<T>& val) const;
         void operator/=(const valarray<T>& val) const;
         void operator%=(const valarray<T>& val) const;
         void operator+=(const valarray<T>& val) const;
         void operator-=(const valarray<T>& val) const;
         void operator^=(const valarray<T>& val) const;
         void operator&=(const valarray<T>& val) const;
         void operator|=(const valarray<T>& val) const;
         void operator<<=(const valarray<T>& val) const;
         void operator>>=(const valarray<T>& val) const;
    
    
            Applies the indicated operation using elements  from  val
            to the selected elements of the valarray that self refers
            to. Remember that an indirect_array never holds any  ele-
            ments  itself;  it  simply refers to selected elements in
            the valarray used to generate it.
    
    
    
    MEMBER FUNCTIONS
         void operator=(const T& x);
    
    
            Assigns x to the selected elements of the  valarray  that
            self refers to.
    
    
    
    EXAMPLE
         //
         // indirect_array.cpp
         //
         #include "valarray.h" // Contains a valarray stream inserter
         using namespace std;
    
         int main(void)
         {
          int ibuf[10] = {0,1,2,3,4,5,6,7,8,9};
          size_t sbuf[6] = {0,2,3,4,7,8};
    
           // create a valarray of ints
          valarray<int>         vi(ibuf,10);
    
           // create a valarray of indices for a selector
          valarray<size_t> selector(sbuf,6);
    
           // print out the valarray<int>
          cout << vi << endl;
    
           // Get a indirect_array
           // and assign that indirect to another valarray
          indirect_array<int> select = vi[selector];
          valarray<int> vi3 = select;
    
           // print out the selective array
          cout << vi3 << endl;
    
           // Double the selected values
          select += vi3;
    
           // print out vi1 again
          cout << vi << endl;
    
          return 0;
         }
    
         Program Output
    
    
    
         [0,1,2,3,4,5,6,7,8,9]
         [0,2,3,4,7,8]
         [0,1,4,6,8,5,6,14,16,9]
    
    
    
    WARNINGS
         If your compiler does not support namespaces,  then  you  do
         not need the using declaration for std.
    
    
    
    SEE ALSO
         slice,   slice_array,   valarray,   gslice,    gslice_array,
         mask_array
    
    
    
    


    Поиск по тексту MAN-ов: 




    Партнёры:
    PostgresPro
    Inferno Solutions
    Hosting by Hoster.ru
    Хостинг:

    Закладки на сайте
    Проследить за страницей
    Created 1996-2024 by Maxim Chirkov
    Добавить, Поддержать, Вебмастеру