functions satisfying "one-one iff onto"  Hello Everybody. 
I need some more examples for the following really interesting phenomenon:
   A function from the class ... is one-one iff it is onto. 

Some examples I know:
1) Finite set case: functions from $\lbrace 1,2,\dots,n\rbrace$ to itself is one-one iff onto.
2) Linear operators $T\colon V\rightarrow V,$ where $V$ is a finite-dimensional vector space is also one-one iff onto.
3) Linear operators of the from (I-K) where K is some compact operator acting on a Banach space satisfies this property. This is the famous result of Fredholm. 
It is very easy to find domains where the result fails. 
I remember my teacher telling me that 'compactness is the next best thing to finiteness', hence this result which trivially holds in the finite case can happen only in the compact setting. I would like to know, if this is really the case or are there any other examples? 
Thank you in advance. 
EDIT: Looking at some answers, I thought it is better if the scope of the question is broadened. 
Does injection (surjection) imply surjection (injection) and isomorphism/isometry? (i.e. by assuming one-one can I get ontoness and structure preserving properties free)
 A: Although I tend to shy away from list questions, this is
more fun to contemplate than the pile of exams on my desk right now.
So take a compact Riemann surface $X$ with genus $g\ge 2$. A nonconstant holomorphic
self map $f:X\to X$ is necessarily an isomorphism. Proof: Surjectivity is automatic by, for
example, the open mapping theorem. If $f$ were not injective, then it would have
a degree $d>1$. But the Riemann-Hurwitz formula would give $g-1\ge d(g-1)$ which is impossible. 
A: Uday asked about the double implication "one-to-one iff onto".  Here's an observation about the relationship between the two different directions of implication, taken from here.
Let $\mathbf{M}$ be a symmetric monoidal closed category.  (This is overkill, but I won't attempt to be more precise.)  Suppose we have in $\mathbf{M}$ two distinguished classes of map, called the "injections" and the "surjections", with the following two properties: (i) if $s\colon X \to Y$ is a surjection then for all $Z$, the induced map
$$
s^*\colon \mathbf{Hom}(Y, Z) \to \mathbf{Hom}(X, Z)
$$
is an injection, and (ii) any surjection with a left inverse is an isomorphism.  Suppose, finally, that every injective endomorphism in $\mathbf{M}$ is an isomorphism.  Then every surjective endomorphism in $\mathbf{M}$ is an isomorphism.
Proof: let $s\colon X \to X$ be a surjective endomorphism.  Then $s^*\colon \mathbf{Hom}(X, X) \to \mathbf{Hom}(X, X)$ is an injective endomorphism, and therefore an isomorphism. It follows that there exists $t\colon X \to X$ such that $s^*(t) = 1_X$, that is, $t\circ s = 1_X$.  But then $s$ is a surjection with a left inverse, so $s$ is an isomorphism.
The hypotheses hold in the category of finite sets, the category of finite-dimensional vector spaces, and the category of compact metric spaces.  In the last case, the maps are the distance-decreasing maps (in the weak sense), "injection" should be interpreted as "isometry into", and "surjection" has its usual meaning.   
In particular, if you already know that every isometry from a compact metric space into itself is surjective, this lets you deduce that every distance-decreasing surjection from a compact metric space to itself is an isometry.
A: (edited slightly) A one to one continuous map between two compact $n$-dimensional manifolds without boundary having equal numbers of components must be onto, and in fact a homeomorphism. 
The image of any connected component must be connected, open (by invariance of domain), and closed (by compactness), and therefore must be a component.
A: A surjective endomorphism of a finitely generated residually finite group is an isomorphism. 
A: If $A$ is a ring and $M$ is a finitely generated $A$-module, then an $A$-module endomorphism $f:M\rightarrow M$ is surjective iff it is an isomorphism.
A: Let $G$ be a sofic group (see this survey article of Pestov for the definition and various results) - all amenable groups are sofic, as are all free groups, and no groups are known to be non-sofic. Let $X=\{0,1\}^G$ with the product topology and let $f: X \to X$ be a continuous function which is also a right $G$-map, here $G$ acts on $X$ by shifts. Then if $f$ is injective, it is automatically surjective - this is Gromov's partial solution to the Gottschalk surjunctivity conjecture, which I think is also mentioned in Pestov's article.
Now this is not what your question asked for, but if we now look at $C(X)$ and the induced algebra homomorphism $f^* : C(X) \to C(X)$, then
$f^*$ surjective $\iff$ $f$ is injective (Tietze/Urysohn) $\iff$ $f$ is bijective (above) $\iff$ $f^*$ bijective (Tietze/Urysohn)
A: Let $R$ be a right perfect ring. Then an endomorphism on a finitely presented left $R$-module is injective if and only if it is surjective: reference. 
A: If $f : S \to S$ is volume preserving and $S \subseteq \mathbb{R}^n$ has finite volume, then f is injective iff f is surjective.
There is a very elegant proof of Koebe–Andreev–Thurston theorem (given in the book on combinatorial geometry by Agarwal and Pach) using this property.
A: Let $G$ be a discrete group, and let $T:\ell^2(G)\to \ell^2(G)$ be a bounded linear operator which commutes with all right translations: that is, if $\xi\in \ell^2(G)$ and $g\in G$ then $T(\xi\cdot g) =T(\xi)\cdot g$. (In other words, $T$ belongs to the group von Neumann algebra.) Then if $T$ is surjective, it is invertible.
This follows from combining a result of Kaplansky with the fact that $C^\ast$-algebras are inverse-closed in containing $C^\ast$-algebras. My own feeling is that the result is tacit folklore but in any case it follows by duality from Theorem 3.2 in this paper.
A: This addresses the "broader scope" of the question and possibly the comments of Uday on Donu's answer: An injective morphism from an affine algebraic variety over an algebraically closed field to itself is also surjective. Moreover, probably even more surprising is the fact that in the case that the field has characteristic zero (and of course algebraically closed), an injective endomorphism is actually a polynomial automorphism (that is the inverse is also a polynomial map!). See e.g. Chapter 4 of van den Essen's "Polynomial Automorphisms" for proofs of both these statements. Also from the same book: the map $x \mapsto x^3$ from $\mathbb{Q} \to \mathbb{Q}$ shows the necessity of algebraic closedness of the field, and the Frobenius automorphism $x \mapsto x^p$ of an algebraically closed field of characteristic $p > 0$ shows that the second statement is false for positive characteristic. Also, note that both statements are automatically true for proper varieties.
A: If $G \subset \mathbb{C}^n$ is a domain and $f: G \mapsto \mathbb{C}^n$ is an injective  holomorphic mapping, then also $f(G)$ is a domain and $f: G \mapsto f(G)$ is biholomorphic.
This follows from the fact that, under the same assumptions, if $f$ is injective, then det $J_f(z) \ne 0$ for every $z \in G$. ($J_f$ denotes the complex jacobian.)
A: Tom Leinster was talking about this here
A: If $A$ is a noetherian ring, then a ring homomorphism $f: A \to A$ is surjective iff it is an isomorphism. 
(see the accepted answer of this question) 
A: The multiplication maps of modules over an Artin Ring have this property. Artin rings similarly generalize both finite sets and vectors spaces.
A: The Dixmier conjecture  involves an even stronger statement. Let $A_n$ be the Weyl algebra, which is the algebra of polynomial differential operators on $\mathbb C[x_1,\ldots,x_n]$. The conjecture is that any algebra map $f:A_n \to A_n$ is an isomorphism. (Of course, it isn't hard to see that $A_n$ has no two-sided ideals, so any such $f$ is automatically injective.)
It was recently proved that the Dixmier conjecture is stably equivalent to the Jacobian conjecture, in the sense that if one conjecture is true for all $n$, then so is the other. (References are given in the wikipedia page.)
A: An isometry (i.e. distance preserving map) between metric spaces is automatically injective.
