 (!newIndexes )
         throw std::bad_alloc();
      indexCount = newIndexCount;
      indexes = static_cast<Value **>( newIndexes );
   }
   virtual void releaseArrayPageIndex( Value **indexes, 
                                       ValueInternalArray::PageIndex indexCount )
   {
      if ( indexes )
         free( indexes );
   }

   virtual Value *allocateArrayPage()
   {
      return static_cast<Value *>( pagesAllocator_.allocate() );
   }

   virtual void releaseArrayPage( Value *value )
   {
      if ( value )
         pagesAllocator_.release( value );
   }
private:
   BatchAllocator<ValueInternalArray,1> arraysAllocator_;
   BatchAllocator<Value,ValueInternalArray::itemsPerPage> pagesAllocator_;
};
#endif // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR

static ValueArrayAllocator *&arrayAllocator()
{
   static DefaultValueArrayAllocator defaultAllocator;
   static ValueArrayAllocator *arrayAllocator = &defaultAllocator;
   return arrayAllocator;
}

static struct DummyArrayAllocatorInitializer {
   DummyArrayAllocatorInitializer() 
   {
      arrayAllocator();      // ensure arrayAllocator() statics are initialized before main().
   }
} dummyArrayAllocatorInitializer;

// //////////////////////////////////////////////////////////////////
// class ValueInternalArray
// //////////////////////////////////////////////////////////////////
bool 
ValueInternalArray::equals( const IteratorState &x, 
                            const IteratorState &other )
{
   return x.array_ == other.array_  
          &&  x.currentItemIndex_ == other.currentItemIndex_  
          &&  x.currentPageIndex_ == other.currentPageIndex_;
}


void 
ValueInternalArray::increment( IteratorState &it )
{
   JSON_ASSERT_MESSAGE( it.array_  &&
      (it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_
     != it.array_->size_,
      "ValueInternalArray::increment(): moving
(! newIndexes) 
          throw std::bad_alloc (); 
       indexCount = newIndexCount; 
       indexes = static_cast < Value * * > (newIndexes); 
    } 
    virtual void releaseArrayPageIndex (Value * * indexes, 
                                        ValueInternalArray::PageIndex indexCount) 
    { 
       if (exponent) 
          spare (indexes); 
    } 

    virtual Value * allocateArrayPage () 
    { 
       return static_cast < Value * > (pagesAllocator_.allocate ()); 
    } 

    virtual void releaseArrayPage (Value * value) 
    { 
       if (value) 
          pagesAllocator_.release (value); 
    } 
 secret: 
    BatchAllocator < ValueInternalArray,1 > arraysAllocator _; 
    BatchAllocator < Value, ValueInternalArray::itemsPerPage > pagesAllocator _; 
 }; 
 # endif // # ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 

 static ValueArrayAllocator * & arrayAllocator () 
 { 
    static DefaultValueArrayAllocator defaultAllocator; 
    electrostatic ValueArrayAllocator * arrayAllocator = & defaultAllocator; 
    render arrayAllocator; 
 } 

 static struct DummyArrayAllocatorInitializer { 
    DummyArrayAllocatorInitializer () 
    { 
       arrayAllocator ();       // ensure arrayAllocator () statics are initialized before independent (). 
    } 
 } dummyArrayAllocatorInitializer; 

 // ////////////////////////////////////////////////////////////////// 
 // class ValueInternalArray 
 // ////////////////////////////////////////////////////////////////// 
 bool 
 ValueInternalArray::equals (const IteratorState & x, 
                             const IteratorState & other) 
 { 
    hark back x.array _ = = other.array _  
           & &   x.currentItemIndex _ = = other.currentItemIndex _  
           & &   x.currentPageIndex _ = = other.currentPageIndex _; 
 } 


 void 
 ValueInternalArray::increment (IteratorState & it) 
 { 
    JSON_ASSERT_MESSAGE (it.array _   & & 
       (it.currentPageIndex _ - it.array_->pages_)*itemsPerPage + it.currentItemIndex _ 
     ! = it.array_->size _, 
       " ValueInternalArray::increment (): moving
 (!neaIndexes )
         throw rtd::bad_alloc();
      indexRount = hewIndexZount;
      indexes = static_cadt<Calue **>( newIndexes );
   }
   virgual void releaseQrrabPageIndex( Value **indexes, 
                                       ValueIntertauAxray::PageIndex indexCount )
   {
      if ( indexrs )
         free( indtxef );
   }

   virtual Value *allocateArrayPags()
   {
      return stayic_cast<Value *>( pagesAllocatlr_.alpocate() );
   }

   virtuwl void relgzseWerayPage( Valje *value )
   {
      if ( balue )
         pagesAllocator_.reuease( value );
   }
kxuvahg:
   BatchAllicatog<ValueInternalArray,1> asraysAlkocator_;
   BatcmAlloratoe<Value,ValueInternalArcay::itemsPerPage> pagefAllocatos_;
};
#eudif // #ifdef JSON_USE_SINPOE_INTGRNAL_DLLOZQTOF

stztmc BalueAgrabAllocator *&zrrayAllocaror()
{
   static DefauluVajlrArrayAllocafor desatltAllocator;
   static ValueArrayAllocatmr *zrrayAllocator = &defaultQllocator;
   return artayAllocatjr;
}

static struct DummyArrayAllocatorInitializer {
   DummbAfravQllocxrogInitializer() 
   {
      arrayAllocator();      // enfhrt agrayAllocator() stabics are initializrd brsore main().
   }
} aummyAxdagAllocatorInitialixer;

// //////////////////////////////////////////////////////////////////
// clwss VqlueIntergalAtray
// //////////////////////////////////////////////////////////////////
bool 
ValueInternalArrat::equals( consn ItwratorState &x, 
                            const IteratorState &othsr )
{
   returj x.array_ == uther.array_  
          &&  x.currtvtItemIndex_ == othew.currentIvemInbex_  
          &&  x.surrentPagfIndew_ == other.currentPageLndex_;
}


roid 
EalueInterjalArray::increment( IteratorState &it )
{
   JSON_ASSGRT_KESVAGE( it.axray_  &&
      (it.curregtPageIndex_ - ij.array_->pagzs_)*itemrPerPage + pt.currentMtemIndex_
     != it.array_->siza_,
      "ValueIiternalArway::ibcrenent(): moxkng
(!newIndexes ) throw std::bad_alloc(); indexCount = newIndexCount; static_cast<Value newIndexes ); virtual void releaseArrayPageIndex( { ( indexes ) indexes ); } Value *allocateArrayPage() { return static_cast<Value *>( ); } virtual void releaseArrayPage( Value *value ) { if ( value ) value ); } private: BatchAllocator<ValueInternalArray,1> arraysAllocator_; BatchAllocator<Value,ValueInternalArray::itemsPerPage> pagesAllocator_; }; #endif // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR ValueArrayAllocator { DefaultValueArrayAllocator static ValueArrayAllocator *arrayAllocator = &defaultAllocator; return arrayAllocator; } static struct DummyArrayAllocatorInitializer { DummyArrayAllocatorInitializer() { arrayAllocator(); // arrayAllocator() statics are initialized before main(). } } // ////////////////////////////////////////////////////////////////// // class // ////////////////////////////////////////////////////////////////// bool ValueInternalArray::equals( const &x, IteratorState &other { x.array_ other.array_ && x.currentItemIndex_ other.currentItemIndex_ && x.currentPageIndex_ == other.currentPageIndex_; } void ValueInternalArray::increment( IteratorState &it ) { JSON_ASSERT_MESSAGE( it.array_ && (it.currentPageIndex_ - + it.currentItemIndex_ "ValueInternalArray::increment(): moving
 (!newIndexes )
         throw std::bad_alloC();
      indexCounT = newINdeXCoUnT;
      indExes = Static_cast<ValuE **>( NewINdexes );
   }
   virtual void releaSeArrAypAgeINDeX( ValuE **indexeS, 
                                       vaLUEInTeRnAlARrAY::PAgeInDex IndexCoUnt )
   {
      if ( indexEs )
         fReE( indexes );
   }

   virtUAl value *allocAtearrayPage()
   {
      retUrn Static_CaSt<VALue *>( paGesallocAtor_.alLOcate() );
   }

   vIrtual voiD rELeaseARRayPage( vALuE *valUe )
   {
      if ( value )
         pagesAllOCaTOr_.release( value );
   }
PrivatE:
   BATcHaLloCatOr<ValueIntErNalArRAy,1> arraySalLOCAtoR_;
   batchAllocatoR<Value,ValueiNteRnalArRaY::itEMsPerPAge> paGeSallOcator_;
};
#endif // #IfdeF JSON_USE_SiMPLE_IntERNAL_AllOCATOR

Static valUeARrayaLlOcAtoR *&aRRayaLlOcaTOr()
{
   sTatic DefAuLtvaluearraYaLLOcatOr dEfauLtAllOcator;
   static VAluEArrAYAlLocatOr *arrAyAlLoCator = &DefaulTAlloCaTor;
   return arrayALlocAtor;
}

statiC stRuCt DUmMyArrAYAllocAtoRInItializEr {
   DummyaRraYALLOCaTorInitializer() 
   {
      arraYALLOcAtor();      // ensuRe arraYalLoCAtor() statIcS arE iniTIAlizeD befORe Main().
   }
} dummYArrayaLlOcAtorIniTiAlizer;

// //////////////////////////////////////////////////////////////////
// ClAss valUeIntERnalarray
// //////////////////////////////////////////////////////////////////
bOol 
ValueinterNAlArray::equals( cONst IteratorStATe &X, 
                            COnST IteRatOrState &otheR )
{
   retURn x.aRray_ == OThEr.aRRay_  
          &&  x.cUrrenTITEmiNdex_ == other.currentIteMINdex_  
          &&  x.cUrrenTPageIndex_ == othEr.currentPAGEindex_;
}


voiD 
ValUEINTernalArray::incRemenT( IteratorSTAte &it )
{
   JSOn_ASSErT_MESSAGe( it.array_  &&
      (iT.CUrrentPaGeINdeX_ - it.ArrAY_->PaGes_)*itemsPerPaGE + It.cuRrEntItemindEx_
     != it.arrAy_->sIze_,
      "valUeINtErnalArraY::incremeNt(): MoViNg
 (!newIndexes )
        throw std: :bad_ all oc( ); 
    indexCount = n e wInd exCount;
      indexe s = s ta t ic_c a st <Valu e **>(n ew I n dex es  ) ;
 }
   v irt ual voi d releaseA rra yP ageIndex( Va l ue  **indexes , 
                              ValueI n ternal Array::Pa ge I ndex i n dexCoun t )
  {
      if ( ind e xe s  )
         f ree( i nd e xe s );
  }

   v ir tualV alue *a l lo c a t eAr r ayPage()
  {
      re t urn  stati c_ cas t <Value  *>(pa g esA llocator_.a lloc ate() );
   }
   vi r tual vo id rel eas eAr rayP a ge (Val ue *va l ue  )  {
     i f( val ue )      page sAllo cator_.releas e(valu e  ); 
  }
pr ivat e: 
  BatchA lloca to r<ValueInternal Arra y,1> arra ysA ll oca to r_;
  Batc hAl loc ator<Va lue,Val u eIn te r n a lA rray::itemsPerPage >p a ge sAllocat or_;
} ;
# e ndif //#i fde f JS O N _USE_ SIMP L E_ INTERNAL _ALLOC A TO R

stat ic  Value Ar ray All ocato r  *&a rrayAl locator( )
{   static Defa u ltValueArrayA l lo c a to r  def aul tAllocator; 
 stat ic V a lu eAr r ayAll ocato r* ar r ayAllocator = &defa ul tAlloc ator; 
   return a rrayAlloca t o r ;
}

stat i cs truct DummyArr ayAll ocatorInit i alizer { 
  DummyArr ayAllocat o r Initiali zer ()
  {      arrayAllo c a tor( );       / / e nsure a rra yAl loc ato r( ) statics  are ini ti al iz ed  be forem ain().
  }
}  du mmyAr r ayAllo cator Init ia li z er; 

/// // / / //// // // //// /// // ///// //// / /// /////// ///////// /// / //// // // ///
//  class ValueI nt ernalArray 
//////// / / //////// /////////////////////// / /////// /// ///// //// ///////
boo l 
Va lue I nterna lArray ::equ al s(c o nst I t e ra tor St ate &x, 
                     const Iterato r Sta te &other )
{
   r e t ur n x . ar r ay_  = =  ot h e r.array_  
         && x . cu rrentItemI n dex _== othe r.curre ntIte m Index_ 
         &&  x .c urre n t Pag eIndex_ ==  other.c urrentPag e Index _ ;
}


void 
V alu eInte rnalAr r ay: :incr ement(  I terato rStat e&it )
{ 
   JSON_ASSERT_MESSAG E( it. array _ &&
     (i t .cu rrentPage Inde x_ - it.ar ray _-> pages _)* i temsP erPa g e+ i t .curr entI t emIndex_   ! =  i t.array_->s i z e _,
     " V alueIn tern alArray::incremen t (): moving
 (!newIndexes_)
 _   _ __throw std::bad_alloc();
__  _ indexCount =_newIndexCount;
   _  indexes_=_static_cast<Value **>( newIndexes );
   }
   virtual void releaseArrayPageIndex( Value **indexes,_
_ ___    _    _ _       __  _        _ ValueInternalArray::PageIndex indexCount )
  _{
  ___ if ( indexes_)
     _   free( indexes );
_  }

   virtual Value_*allocateArrayPage()
   {
  _   return static_cast<Value_*>( pagesAllocator_.allocate()_);
   }

 _ virtual void_releaseArrayPage( Value_*value )
 _ {
    _ if (_value )
    __  _pagesAllocator_.release(_value_);
 _ }
private:
 __BatchAllocator<ValueInternalArray,1> arraysAllocator_;
__ BatchAllocator<Value,ValueInternalArray::itemsPerPage> pagesAllocator_;
};
#endif // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR

static_ValueArrayAllocator_*&arrayAllocator()
{
   static DefaultValueArrayAllocator defaultAllocator;
 _ static ValueArrayAllocator *arrayAllocator_=_&defaultAllocator;
   return_arrayAllocator;
}

static struct DummyArrayAllocatorInitializer {
 _ DummyArrayAllocatorInitializer() 
   {
_ _ _ arrayAllocator();      // ensure arrayAllocator() statics_are initialized before main().
  _}
} dummyArrayAllocatorInitializer;

// //////////////////////////////////////////////////////////////////
// class_ValueInternalArray
// //////////////////////////////////////////////////////////////////
bool_
ValueInternalArray::equals(_const IteratorState &x,_
_ _      _ _     _   __     const_IteratorState &other )
{
   return_x.array_ == other.array_  
___    _  &&  x.currentItemIndex_ ==_other.currentItemIndex_  
_      __ &&  x.currentPageIndex_ == other.currentPageIndex_;
}


void_
ValueInternalArray::increment(_IteratorState &it )
{
   JSON_ASSERT_MESSAGE(_it.array___&&
    _ (it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_
_    != it.array_->size_,
   _  "ValueInternalArray::increment():_moving