Sierra Toolkit  Version of the Day
functional_eastl.h
1 /*
2 Copyright (C) 2005,2009-2010 Electronic Arts, Inc. All rights reserved.
3 
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
7 
8 1. Redistributions of source code must retain the above copyright
9  notice, this list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright
11  notice, this list of conditions and the following disclaimer in the
12  documentation and/or other materials provided with the distribution.
13 3. Neither the name of Electronic Arts, Inc. ("EA") nor the names of
14  its contributors may be used to endorse or promote products derived
15  from this software without specific prior written permission.
16 
17 THIS SOFTWARE IS PROVIDED BY ELECTRONIC ARTS AND ITS CONTRIBUTORS "AS IS" AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL ELECTRONIC ARTS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
30 // EASTL/functional.h
31 // Written and maintained by Paul Pedriana - 2005
33 
34 
35 #ifndef EASTL_FUNCTIONAL_H
36 #define EASTL_FUNCTIONAL_H
37 
38 
39 #include <stk_util/util/config_eastl.h>
40 #include <stk_util/util/type_traits_eastl.h>
41 
42 
43 namespace eastl
44 {
45 
47  // Primary C++ functions
49 
50  template <typename Argument, typename Result>
51  struct unary_function
52  {
53  typedef Argument argument_type;
54  typedef Result result_type;
55  };
56 
57 
58  template <typename Argument1, typename Argument2, typename Result>
59  struct binary_function
60  {
61  typedef Argument1 first_argument_type;
62  typedef Argument2 second_argument_type;
63  typedef Result result_type;
64  };
65 
66 
67  template <typename T>
68  struct plus : public binary_function<T, T, T>
69  {
70  T operator()(const T& a, const T& b) const
71  { return a + b; }
72  };
73 
74  template <typename T>
75  struct minus : public binary_function<T, T, T>
76  {
77  T operator()(const T& a, const T& b) const
78  { return a - b; }
79  };
80 
81  template <typename T>
82  struct multiplies : public binary_function<T, T, T>
83  {
84  T operator()(const T& a, const T& b) const
85  { return a * b; }
86  };
87 
88  template <typename T>
89  struct divides : public binary_function<T, T, T>
90  {
91  T operator()(const T& a, const T& b) const
92  { return a / b; }
93  };
94 
95  template <typename T>
96  struct modulus : public binary_function<T, T, T>
97  {
98  T operator()(const T& a, const T& b) const
99  { return a % b; }
100  };
101 
102  template <typename T>
103  struct negate : public unary_function<T, T>
104  {
105  T operator()(const T& a) const
106  { return -a; }
107  };
108 
109  template <typename T>
110  struct equal_to : public binary_function<T, T, bool>
111  {
112  bool operator()(const T& a, const T& b) const
113  { return a == b; }
114  };
115 
116  template <typename T, typename Compare>
117  bool validate_equal_to(const T& a, const T& b, Compare compare)
118  {
119  return compare(a, b) == compare(b, a);
120  }
121 
122  template <typename T>
123  struct not_equal_to : public binary_function<T, T, bool>
124  {
125  bool operator()(const T& a, const T& b) const
126  { return a != b; }
127  };
128 
129  template <typename T, typename Compare>
130  bool validate_not_equal_to(const T& a, const T& b, Compare compare)
131  {
132  return compare(a, b) == compare(b, a); // We want the not equal comparison results to be equal.
133  }
134 
149  template <typename T>
150  struct str_equal_to : public binary_function<T, T, bool>
151  {
152  bool operator()(T a, T b) const
153  {
154  while(*a && (*a == *b))
155  {
156  ++a;
157  ++b;
158  }
159  return (*a == *b);
160  }
161  };
162 
163  template <typename T>
164  struct greater : public binary_function<T, T, bool>
165  {
166  bool operator()(const T& a, const T& b) const
167  { return a > b; }
168  };
169 
170  template <typename T, typename Compare>
171  bool validate_greater(const T& a, const T& b, Compare compare)
172  {
173  return !compare(a, b) || !compare(b, a); // If (a > b), then !(b > a)
174  }
175 
176  template <typename T>
177  struct less : public binary_function<T, T, bool>
178  {
179  bool operator()(const T& a, const T& b) const
180  { return a < b; }
181  };
182 
183  template <typename T, typename Compare>
184  bool validate_less(const T& a, const T& b, Compare compare)
185  {
186  return !compare(a, b) || !compare(b, a); // If (a < b), then !(b < a)
187  }
188 
189  template <typename T>
190  struct greater_equal : public binary_function<T, T, bool>
191  {
192  bool operator()(const T& a, const T& b) const
193  { return a >= b; }
194  };
195 
196  template <typename T, typename Compare>
197  bool validate_greater_equal(const T& a, const T& b, Compare compare)
198  {
199  return !compare(a, b) || !compare(b, a); // If (a >= b), then !(b >= a)
200  }
201 
202  template <typename T>
203  struct less_equal : public binary_function<T, T, bool>
204  {
205  bool operator()(const T& a, const T& b) const
206  { return a <= b; }
207  };
208 
209  template <typename T, typename Compare>
210  bool validate_less_equal(const T& a, const T& b, Compare compare)
211  {
212  return !compare(a, b) || !compare(b, a); // If (a <= b), then !(b <= a)
213  }
214 
215  template <typename T>
216  struct logical_and : public binary_function<T, T, bool>
217  {
218  bool operator()(const T& a, const T& b) const
219  { return a && b; }
220  };
221 
222  template <typename T>
223  struct logical_or : public binary_function<T, T, bool>
224  {
225  bool operator()(const T& a, const T& b) const
226  { return a || b; }
227  };
228 
229  template <typename T>
230  struct logical_not : public unary_function<T, bool>
231  {
232  bool operator()(const T& a) const
233  { return !a; }
234  };
235 
236 
237 
239  // Dual type functions
241 
242  template <typename T, typename U>
243  struct equal_to_2 : public binary_function<T, U, bool>
244  {
245  bool operator()(const T& a, const U& b) const
246  { return a == b; }
247  };
248 
249  template <typename T, typename U>
250  struct not_equal_to_2 : public binary_function<T, U, bool>
251  {
252  bool operator()(const T& a, const U& b) const
253  { return a != b; }
254  };
255 
256  template <typename T, typename U>
257  struct less_2 : public binary_function<T, U, bool>
258  {
259  bool operator()(const T& a, const U& b) const
260  { return a < b; }
261  };
262 
263 
264 
265 
268  template <typename Predicate>
269  class unary_negate : public unary_function<typename Predicate::argument_type, bool>
270  {
271  protected:
272  Predicate mPredicate;
273  public:
274  explicit unary_negate(const Predicate& a)
275  : mPredicate(a) {}
276  bool operator()(const typename Predicate::argument_type& a) const
277  { return !mPredicate(a); }
278  };
279 
280  template <typename Predicate>
281  inline unary_negate<Predicate> not1(const Predicate& predicate)
282  { return unary_negate<Predicate>(predicate); }
283 
284 
285 
288  template <typename Predicate>
289  class binary_negate : public binary_function<typename Predicate::first_argument_type, typename Predicate::second_argument_type, bool>
290  {
291  protected:
292  Predicate mPredicate;
293  public:
294  explicit binary_negate(const Predicate& a)
295  : mPredicate(a) { }
296  bool operator()(const typename Predicate::first_argument_type& a, const typename Predicate::second_argument_type& b) const
297  { return !mPredicate(a, b); }
298  };
299 
300  template <typename Predicate>
301  inline binary_negate<Predicate> not2(const Predicate& predicate)
302  { return binary_negate<Predicate>(predicate); }
303 
304 
305 
306 
308  // bind
310 
313  template <typename Operation>
314  class binder1st : public unary_function<typename Operation::second_argument_type, typename Operation::result_type>
315  {
316  protected:
317  typename Operation::first_argument_type value;
318  Operation op;
319 
320  public:
321  binder1st(const Operation& x, const typename Operation::first_argument_type& y)
322  : value(y), op(x) { }
323 
324  typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const
325  { return op(value, x); }
326 
327  typename Operation::result_type operator()(typename Operation::second_argument_type& x) const
328  { return op(value, x); }
329  };
330 
331 
332  template <typename Operation, typename T>
333  inline binder1st<Operation> bind1st(const Operation& op, const T& x)
334  {
335  typedef typename Operation::first_argument_type value;
336  return binder1st<Operation>(op, value(x));
337  }
338 
339 
342  template <typename Operation>
343  class binder2nd : public unary_function<typename Operation::first_argument_type, typename Operation::result_type>
344  {
345  protected:
346  Operation op;
347  typename Operation::second_argument_type value;
348 
349  public:
350  binder2nd(const Operation& x, const typename Operation::second_argument_type& y)
351  : op(x), value(y) { }
352 
353  typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const
354  { return op(x, value); }
355 
356  typename Operation::result_type operator()(typename Operation::first_argument_type& x) const
357  { return op(x, value); }
358  };
359 
360 
361  template <typename Operation, typename T>
362  inline binder2nd<Operation> bind2nd(const Operation& op, const T& x)
363  {
364  typedef typename Operation::second_argument_type value;
365  return binder2nd<Operation>(op, value(x));
366  }
367 
368 
369 
370 
372  // pointer_to_unary_function
374 
386  template <typename Arg, typename Result>
387  class pointer_to_unary_function : public unary_function<Arg, Result>
388  {
389  protected:
390  Result (*mpFunction)(Arg);
391 
392  public:
394  { }
395 
396  explicit pointer_to_unary_function(Result (*pFunction)(Arg))
397  : mpFunction(pFunction) { }
398 
399  Result operator()(Arg x) const
400  { return mpFunction(x); }
401  };
402 
403 
412  template <typename Arg, typename Result>
413  inline pointer_to_unary_function<Arg, Result> ptr_fun(Result (*pFunction)(Arg))
414  { return pointer_to_unary_function<Arg, Result>(pFunction); }
415 
416 
417 
418 
419 
421  // pointer_to_binary_function
423 
430  template <typename Arg1, typename Arg2, typename Result>
431  class pointer_to_binary_function : public binary_function<Arg1, Arg2, Result>
432  {
433  protected:
434  Result (*mpFunction)(Arg1, Arg2);
435 
436  public:
438  { }
439 
440  explicit pointer_to_binary_function(Result (*pFunction)(Arg1, Arg2))
441  : mpFunction(pFunction) {}
442 
443  Result operator()(Arg1 x, Arg2 y) const
444  { return mpFunction(x, y); }
445  };
446 
447 
454  template <typename Arg1, typename Arg2, typename Result>
455  inline pointer_to_binary_function<Arg1, Arg2, Result> ptr_fun(Result (*pFunction)(Arg1, Arg2))
457 
458 
459 
460 
461 
462 
464  // mem_fun
465  // mem_fun1
466  //
467  // Note that mem_fun calls member functions via *pointers* to classes
468  // and not instances of classes. mem_fun_ref is for calling functions
469  // via instances of classes or references to classes.
470  //
472 
477  template <typename Result, typename T>
478  class mem_fun_t : public unary_function<T*, Result>
479  {
480  public:
481  typedef Result (T::*MemberFunction)();
482 
483  EA_FORCE_INLINE explicit mem_fun_t(MemberFunction pMemberFunction)
484  : mpMemberFunction(pMemberFunction)
485  {
486  // Empty
487  }
488 
489  EA_FORCE_INLINE Result operator()(T* pT) const
490  {
491  return (pT->*mpMemberFunction)();
492  }
493 
494  protected:
495  MemberFunction mpMemberFunction;
496  };
497 
498 
503  template <typename Result, typename T, typename Argument>
504  class mem_fun1_t : public binary_function<T*, Argument, Result>
505  {
506  public:
507  typedef Result (T::*MemberFunction)(Argument);
508 
509  EA_FORCE_INLINE explicit mem_fun1_t(MemberFunction pMemberFunction)
510  : mpMemberFunction(pMemberFunction)
511  {
512  // Empty
513  }
514 
515  EA_FORCE_INLINE Result operator()(T* pT, Argument arg) const
516  {
517  return (pT->*mpMemberFunction)(arg);
518  }
519 
520  protected:
521  MemberFunction mpMemberFunction;
522  };
523 
524 
532  template <typename Result, typename T>
533  class const_mem_fun_t : public unary_function<const T*, Result>
534  {
535  public:
536  typedef Result (T::*MemberFunction)() const;
537 
538  EA_FORCE_INLINE explicit const_mem_fun_t(MemberFunction pMemberFunction)
539  : mpMemberFunction(pMemberFunction)
540  {
541  // Empty
542  }
543 
544  EA_FORCE_INLINE Result operator()(const T* pT) const
545  {
546  return (pT->*mpMemberFunction)();
547  }
548 
549  protected:
550  MemberFunction mpMemberFunction;
551  };
552 
553 
561  template <typename Result, typename T, typename Argument>
562  class const_mem_fun1_t : public binary_function<const T*, Argument, Result>
563  {
564  public:
565  typedef Result (T::*MemberFunction)(Argument) const;
566 
567  EA_FORCE_INLINE explicit const_mem_fun1_t(MemberFunction pMemberFunction)
568  : mpMemberFunction(pMemberFunction)
569  {
570  // Empty
571  }
572 
573  EA_FORCE_INLINE Result operator()(const T* pT, Argument arg) const
574  {
575  return (pT->*mpMemberFunction)(arg);
576  }
577 
578  protected:
579  MemberFunction mpMemberFunction;
580  };
581 
582 
592  template <typename Result, typename T>
593  EA_FORCE_INLINE mem_fun_t<Result, T>
594  mem_fun(Result (T::*MemberFunction)())
595  {
596  return eastl::mem_fun_t<Result, T>(MemberFunction);
597  }
598 
599  template <typename Result, typename T, typename Argument>
600  EA_FORCE_INLINE mem_fun1_t<Result, T, Argument>
601  mem_fun(Result (T::*MemberFunction)(Argument))
602  {
603  return eastl::mem_fun1_t<Result, T, Argument>(MemberFunction);
604  }
605 
606  template <typename Result, typename T>
607  EA_FORCE_INLINE const_mem_fun_t<Result, T>
608  mem_fun(Result (T::*MemberFunction)() const)
609  {
610  return eastl::const_mem_fun_t<Result, T>(MemberFunction);
611  }
612 
613  template <typename Result, typename T, typename Argument>
614  EA_FORCE_INLINE const_mem_fun1_t<Result, T, Argument>
615  mem_fun(Result (T::*MemberFunction)(Argument) const)
616  {
617  return eastl::const_mem_fun1_t<Result, T, Argument>(MemberFunction);
618  }
619 
620 
621 
622 
623 
625  // mem_fun_ref
626  // mem_fun1_ref
627  //
629 
632  template <typename Result, typename T>
633  class mem_fun_ref_t : public unary_function<T, Result>
634  {
635  public:
636  typedef Result (T::*MemberFunction)();
637 
638  EA_FORCE_INLINE explicit mem_fun_ref_t(MemberFunction pMemberFunction)
639  : mpMemberFunction(pMemberFunction)
640  {
641  // Empty
642  }
643 
644  EA_FORCE_INLINE Result operator()(T& t) const
645  {
646  return (t.*mpMemberFunction)();
647  }
648 
649  protected:
650  MemberFunction mpMemberFunction;
651  };
652 
653 
656  template <typename Result, typename T, typename Argument>
657  class mem_fun1_ref_t : public binary_function<T, Argument, Result>
658  {
659  public:
660  typedef Result (T::*MemberFunction)(Argument);
661 
662  EA_FORCE_INLINE explicit mem_fun1_ref_t(MemberFunction pMemberFunction)
663  : mpMemberFunction(pMemberFunction)
664  {
665  // Empty
666  }
667 
668  EA_FORCE_INLINE Result operator()(T& t, Argument arg) const
669  {
670  return (t.*mpMemberFunction)(arg);
671  }
672 
673  protected:
674  MemberFunction mpMemberFunction;
675  };
676 
677 
680  template <typename Result, typename T>
681  class const_mem_fun_ref_t : public unary_function<T, Result>
682  {
683  public:
684  typedef Result (T::*MemberFunction)() const;
685 
686  EA_FORCE_INLINE explicit const_mem_fun_ref_t(MemberFunction pMemberFunction)
687  : mpMemberFunction(pMemberFunction)
688  {
689  // Empty
690  }
691 
692  EA_FORCE_INLINE Result operator()(const T& t) const
693  {
694  return (t.*mpMemberFunction)();
695  }
696 
697  protected:
698  MemberFunction mpMemberFunction;
699  };
700 
701 
704  template <typename Result, typename T, typename Argument>
705  class const_mem_fun1_ref_t : public binary_function<T, Argument, Result>
706  {
707  public:
708  typedef Result (T::*MemberFunction)(Argument) const;
709 
710  EA_FORCE_INLINE explicit const_mem_fun1_ref_t(MemberFunction pMemberFunction)
711  : mpMemberFunction(pMemberFunction)
712  {
713  // Empty
714  }
715 
716  EA_FORCE_INLINE Result operator()(const T& t, Argument arg) const
717  {
718  return (t.*mpMemberFunction)(arg);
719  }
720 
721  protected:
722  MemberFunction mpMemberFunction;
723  };
724 
725 
732  template <typename Result, typename T>
733  EA_FORCE_INLINE mem_fun_ref_t<Result, T>
734  mem_fun_ref(Result (T::*MemberFunction)())
735  {
736  return eastl::mem_fun_ref_t<Result, T>(MemberFunction);
737  }
738 
739  template <typename Result, typename T, typename Argument>
740  EA_FORCE_INLINE mem_fun1_ref_t<Result, T, Argument>
741  mem_fun_ref(Result (T::*MemberFunction)(Argument))
742  {
743  return eastl::mem_fun1_ref_t<Result, T, Argument>(MemberFunction);
744  }
745 
746  template <typename Result, typename T>
747  EA_FORCE_INLINE const_mem_fun_ref_t<Result, T>
748  mem_fun_ref(Result (T::*MemberFunction)() const)
749  {
750  return eastl::const_mem_fun_ref_t<Result, T>(MemberFunction);
751  }
752 
753  template <typename Result, typename T, typename Argument>
754  EA_FORCE_INLINE const_mem_fun1_ref_t<Result, T, Argument>
755  mem_fun_ref(Result (T::*MemberFunction)(Argument) const)
756  {
758  }
759 
760 
761 
762 
764  // hash
766 
767  template <typename T> struct hash;
768 
769  template <typename T> struct hash<T*> // Note that we use the pointer as-is and don't divide by sizeof(T*). This is because the table is of a prime size and this division doesn't benefit distribution.
770  { size_t operator()(T* p) const { return size_t(uintptr_t(p)); } };
771 
772  template <> struct hash<bool>
773  { size_t operator()(bool val) const { return static_cast<size_t>(val); } };
774 
775  template <> struct hash<char>
776  { size_t operator()(char val) const { return static_cast<size_t>(val); } };
777 
778  template <> struct hash<signed char>
779  { size_t operator()(signed char val) const { return static_cast<size_t>(val); } };
780 
781  template <> struct hash<unsigned char>
782  { size_t operator()(unsigned char val) const { return static_cast<size_t>(val); } };
783 
784  #ifndef EA_WCHAR_T_NON_NATIVE // If wchar_t is a native type instead of simply a define to an existing type...
785  template <> struct hash<wchar_t>
786  { size_t operator()(wchar_t val) const { return static_cast<size_t>(val); } };
787  #endif
788 
789  template <> struct hash<signed short>
790  { size_t operator()(short val) const { return static_cast<size_t>(val); } };
791 
792  template <> struct hash<unsigned short>
793  { size_t operator()(unsigned short val) const { return static_cast<size_t>(val); } };
794 
795  template <> struct hash<signed int>
796  { size_t operator()(signed int val) const { return static_cast<size_t>(val); } };
797 
798  template <> struct hash<unsigned int>
799  { size_t operator()(unsigned int val) const { return static_cast<size_t>(val); } };
800 
801  template <> struct hash<signed long>
802  { size_t operator()(signed long val) const { return static_cast<size_t>(val); } };
803 
804  template <> struct hash<unsigned long>
805  { size_t operator()(unsigned long val) const { return static_cast<size_t>(val); } };
806 
807  template <> struct hash<signed long long>
808  { size_t operator()(signed long long val) const { return static_cast<size_t>(val); } };
809 
810  template <> struct hash<unsigned long long>
811  { size_t operator()(unsigned long long val) const { return static_cast<size_t>(val); } };
812 
813  template <> struct hash<float>
814  { size_t operator()(float val) const { return static_cast<size_t>(val); } };
815 
816  template <> struct hash<double>
817  { size_t operator()(double val) const { return static_cast<size_t>(val); } };
818 
819  template <> struct hash<long double>
820  { size_t operator()(long double val) const { return static_cast<size_t>(val); } };
821 
822 
824  // string hashes
825  //
826  // Note that our string hashes here intentionally are slow for long strings.
827  // The reasoning for this is so:
828  // - The large majority of hashed strings are only a few bytes long.
829  // - The hash function is significantly more efficient if it can make this assumption.
830  // - The user is welcome to make a custom hash for those uncommon cases where
831  // long strings need to be hashed. Indeed, the user can probably make a
832  // special hash customized for such strings that's better than what we provide.
834 
835  template <> struct hash<char8_t*>
836  {
837  size_t operator()(const char8_t* p) const
838  {
839  size_t c, result = 2166136261U; // FNV1 hash. Perhaps the best string hash.
840  while((c = (uint8_t)*p++) != 0) // Using '!=' disables compiler warnings.
841  result = (result * 16777619) ^ c;
842  return (size_t)result;
843  }
844  };
845 
846  template <> struct hash<const char8_t*>
847  {
848  size_t operator()(const char8_t* p) const
849  {
850  size_t c, result = 2166136261U;
851  while((c = (uint8_t)*p++) != 0) // cast to unsigned 8 bit.
852  result = (result * 16777619) ^ c;
853  return (size_t)result;
854  }
855  };
856 
857  template <> struct hash<char16_t*>
858  {
859  size_t operator()(const char16_t* p) const
860  {
861  size_t c, result = 2166136261U;
862  while((c = (uint16_t)*p++) != 0) // cast to unsigned 16 bit.
863  result = (result * 16777619) ^ c;
864  return (size_t)result;
865  }
866  };
867 
868  template <> struct hash<const char16_t*>
869  {
870  size_t operator()(const char16_t* p) const
871  {
872  size_t c, result = 2166136261U;
873  while((c = (uint16_t)*p++) != 0) // cast to unsigned 16 bit.
874  result = (result * 16777619) ^ c;
875  return (size_t)result;
876  }
877  };
878 
879  template <> struct hash<char32_t*>
880  {
881  size_t operator()(const char32_t* p) const
882  {
883  size_t c, result = 2166136261U;
884  while((c = (uint32_t)*p++) != 0) // cast to unsigned 32 bit.
885  result = (result * 16777619) ^ c;
886  return (size_t)result;
887  }
888  };
889 
890  template <> struct hash<const char32_t*>
891  {
892  size_t operator()(const char32_t* p) const
893  {
894  size_t c, result = 2166136261U;
895  while((c = (uint32_t)*p++) != 0) // cast to unsigned 32 bit.
896  result = (result * 16777619) ^ c;
897  return (size_t)result;
898  }
899  };
900 
908  template <typename String>
909  struct string_hash
910  {
911  typedef String string_type;
912  typedef typename String::value_type value_type;
913  typedef typename eastl::add_unsigned<value_type>::type unsigned_value_type;
914 
915  size_t operator()(const string_type& s) const
916  {
917  const unsigned_value_type* p = (const unsigned_value_type*)s.c_str();
918  size_t c, result = 2166136261U;
919  while((c = *p++) != 0)
920  result = (result * 16777619) ^ c;
921  return (size_t)result;
922  }
923  };
924 
925 
926 } // namespace eastl
927 
928 
929 #endif // Header include guard
pointer_to_unary_function< Arg, Result > ptr_fun(Result(*pFunction)(Arg))
EA_FORCE_INLINE mem_fun_ref_t< Result, T > mem_fun_ref(Result(T::*MemberFunction)())
EA_FORCE_INLINE mem_fun_t< Result, T > mem_fun(Result(T::*MemberFunction)())
EA Standard Template Library.