Merge 'class nsQuickSortComparator' into 'nsTArray'

RESOLVED FIXED in mozilla14

Status

()

Core
XPCOM
--
trivial
RESOLVED FIXED
7 years ago
5 years ago

People

(Reporter: sgautherie, Assigned: dwarfcrank)

Tracking

Trunk
mozilla14
x86
Windows Server 2003
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Reporter)

Description

7 years ago
{
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-
(Reporter)

Updated

5 years ago
Whiteboard: [good first bug][lang=cpp]

Updated

5 years ago
Whiteboard: [good first bug][lang=cpp] → [good first bug][lang=c++]
(Reporter)

Updated

5 years ago
Depends on: 316782
Whiteboard: [good first bug][lang=c++] → [good first bug][mentor=bsmedberg][lang=c++]
(Assignee)

Comment 1

5 years ago
Created attachment 606299 [details] [diff] [review]
Patch to merge nsQuickSortComparator into nsTArray.

Updated

5 years ago
Attachment #606299 - Flags: review?(benjamin)
https://tbpl.mozilla.org/?tree=Try&rev=c7e312012f53
Attachment #606299 - Flags: review?(benjamin) → review+

Updated

5 years ago
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
Last Resolved: 5 years ago
Resolution: --- → FIXED
(Reporter)

Comment 5

5 years ago
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.
(Reporter)

Updated

5 years ago
Whiteboard: [good first bug][mentor=bsmedberg][lang=c++]
You need to log in before you can comment on or make changes to this bug.