Closed Bug 617947 Opened 14 years ago Closed 12 years ago

Merge 'class nsQuickSortComparator' into 'nsTArray'

Categories

(Core :: XPCOM, defect)

x86
Windows Server 2003
defect
Not set
trivial

Tracking

()

RESOLVED FIXED
mozilla14

People

(Reporter: sgautherie, Assigned: dwarfcrank)

References

()

Details

Attachments

(1 file)

{
279 // This class exists because VC6 cannot handle static template functions.
280 // Otherwise, the Compare method would be defined directly on nsTArray.
281 template <class E, class Comparator>
282 class nsQuickSortComparator
283 {
284 public:
285   typedef E elem_type;
286   // This function is meant to be used with the NS_QuickSort function.  It
287   // maps the callback API expected by NS_QuickSort to the Comparator API
288   // used by nsTArray.  See nsTArray::Sort.
289   static int Compare(const void* e1, const void* e2, void *data) {
290     const Comparator* c = reinterpret_cast<const Comparator*>(data);
291     const elem_type* a = static_cast<const elem_type*>(e1);
292     const elem_type* b = static_cast<const elem_type*>(e2);
293     return c->LessThan(*a, *b) ? -1 : (c->Equals(*a, *b) ? 0 : 1);
294   }
295 };
}
Flags: in-testsuite-
Whiteboard: [good first bug][lang=cpp]
Whiteboard: [good first bug][lang=cpp] → [good first bug][lang=c++]
Depends on: 316782
Whiteboard: [good first bug][lang=c++] → [good first bug][mentor=bsmedberg][lang=c++]
Attachment #606299 - Flags: review?(benjamin)
Attachment #606299 - Flags: review?(benjamin) → review+
Assignee: nobody → matias.juntunen
Keywords: checkin-needed
https://hg.mozilla.org/integration/mozilla-inbound/rev/3e87be93a27d

To make life easier for those checking patches in for you, please follow the directions below for future patches. Thanks!
https://developer.mozilla.org/en/Mercurial_FAQ#How_can_I_generate_a_patch_for_somebody_else_to_check-in_for_me.3F
Keywords: checkin-needed
Target Milestone: --- → mozilla14
https://hg.mozilla.org/mozilla-central/rev/3e87be93a27d
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Comment on attachment 606299 [details] [diff] [review]
Patch to merge nsQuickSortComparator into nsTArray.

Review of attachment 606299 [details] [diff] [review]:
-----------------------------------------------------------------

::: xpcom/glue/nsTArray.h
@@ +1113,5 @@
>    //
>    // Sorting
>    //
> + 
> +  // This function is meant to be used with the NS_QuickSort function.  It

Nit: this is now a method, not a function anymore.
Whiteboard: [good first bug][mentor=bsmedberg][lang=c++]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: