1 #ifndef SQL_ARRAY_INCLUDED 
    2 #define SQL_ARRAY_INCLUDED 
   39     : m_array(el), m_size(size)
 
   42   void reset() { m_array= NULL; m_size= 0; }
 
   44   void reset(Element_type *array, 
size_t size)
 
   57     DBUG_ASSERT(new_size <= m_size);
 
   61   Element_type &operator[](
size_t n)
 
   63     DBUG_ASSERT(n < m_size);
 
   67   const Element_type &operator[](
size_t n)
 const 
   69     DBUG_ASSERT(n < m_size);
 
   73   size_t element_size()
 const { 
return sizeof(Element_type); }
 
   74   size_t size()
 const         { 
return m_size; }
 
   76   bool is_null()
 const { 
return m_array == NULL; }
 
   80     DBUG_ASSERT(m_size > 0);
 
   85   Element_type *array()
 const { 
return m_array; }
 
   89     return m_array == rhs.m_array && m_size == rhs.m_size;
 
   93     return m_array != rhs.m_array || m_size != rhs.m_size;
 
   97   Element_type *m_array;
 
  111     init(prealloc, increment);
 
  114   void init(uint prealloc=16, uint increment=16)
 
  116     my_init_dynamic_array(&array, 
sizeof(Elem), prealloc, increment);
 
  125     return *(((Elem*)array.buffer) + idx);
 
  128   const Elem& 
at(
int idx)
 const 
  130     return *(((Elem*)array.buffer) + idx);
 
  136     DBUG_ASSERT(array.elements >= 1);
 
  137     return (Elem*)array.buffer;
 
  143     DBUG_ASSERT(array.elements >= 1);
 
  144     return (
const Elem*)array.buffer;
 
  150     DBUG_ASSERT(array.elements >= 1);
 
  151     return ((Elem*)array.buffer) + (array.elements - 1);
 
  157     DBUG_ASSERT(array.elements >= 1);
 
  158     return ((
const Elem*)array.buffer) + (array.elements - 1);
 
  167     return insert_dynamic(&array, &el);
 
  173     return *((Elem*)pop_dynamic(&array));
 
  178     delete_dynamic_element(&array, idx);
 
  183     return array.elements;
 
  186   void elements(uint num_elements)
 
  188     DBUG_ASSERT(num_elements <= array.max_element);
 
  189     array.elements= num_elements;
 
  197   void set(uint idx, 
const Elem &el)
 
  199     set_dynamic(&array, &el, idx);
 
  204     delete_dynamic(&array);
 
  207   typedef int (*CMP_FUNC)(
const Elem *el1, 
const Elem *el2);
 
  209   void sort(CMP_FUNC cmp_func)
 
  211     my_qsort(array.buffer, array.elements, 
sizeof(Elem), (qsort_cmp)cmp_func);